-
-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix nested contexts duplicating commands #691
Conversation
I had some difficulty getting the test docker image to work, but with some fiddling, I did get the test runner working for python 3.8 and all the tests for that at least passed. Got these errors trying to run the test docker image:
After temporarily updating the image to just use 3.8, I got this error when running the tests:
|
Thanks for the contribution, I will take a look this week
…On Sat, Jul 29, 2023 at 4:19 PM John Trimble ***@***.***> wrote:
I had some difficulty getting the test docker image to work, but with some
fiddling, I did get the test runner working for python 3.8 and all the
tests for that at least passed.
Got these errors trying to run the test docker image:
=> ERROR [ 7/12] RUN apt-get -y install python3.8 python3.9 python3.10 python3 2.2s
------
> [ 7/12] RUN apt-get -y install python3.8 python3.9 python3.10 python3.11:
#10 0.326 Reading package lists...
#10 1.707 Building dependency tree...
#10 1.901 Reading state information...
#10 2.154 E: Unable to locate package python3.9
#10 2.154 E: Couldn't find any package by glob 'python3.9'
#10 2.154 E: Couldn't find any package by regex 'python3.9'
#10 2.154 E: Unable to locate package python3.11
#10 2.154 E: Couldn't find any package by glob 'python3.11'
#10 2.154 E: Couldn't find any package by regex 'python3.11'
After temporarily updating the image to just use 3.8, I got this error
when running the tests:
docker run -it --rm amoffat/shtest tox -p
py38-locale-utf8-poller-poll: FAIL ✖ in 4.26 seconds
py38-locale-utf8-poller-poll: commands[0]> python test.py
py38-locale-utf8-poller-poll: exit 1 (0.23 seconds) /home/shtest> python test.py pid=40
py38-locale-c-poller-poll: FAIL ✖ in 4.3 seconds
Traceback (most recent call last):
File "test.py", line 27, in <module>
import sh
File "/home/shtest/sh.py", line 70, in <module>
__version__ = metadata.version("sh")
File "/usr/lib/python3.8/importlib/metadata.py", line 472, in version
return distribution(distribution_name).version
File "/usr/lib/python3.8/importlib/metadata.py", line 445, in distribution
return Distribution.from_name(distribution_name)
File "/usr/lib/python3.8/importlib/metadata.py", line 169, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: sh
—
Reply to this email directly, view it on GitHub
<#691 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB7IKKRKSBABJLKYSNTCEDXSWK7ZANCNFSM6AAAAAA24YYAW4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Andrew M
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work
Thanks for reviewing and merging this. Also, thanks for writing and maintaining this library! I use it all the time and it saves me an incredible amount of time and frustration. |
That is great to hear John :) |
This PR fixes an issue where using nested command contexts would duplicate commands upon execution. This comes about because all created commands are prepended by any containing commands used as a with-context. Since commands used as a with-context also get prepended, we end up getting duplicated commands when are contexts are nested.
We solve the problem by simply not prepending to commands used as a context.
Resolves #690