-
Notifications
You must be signed in to change notification settings - Fork 52
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
Use the same interpreter when ptw is called outside of a virtual env #72
Conversation
👍 Thanks for the fix! |
Nice one @jacebrowning 👍 |
@@ -1,6 +1,7 @@ | |||
pytest-watch Changelog | |||
====================== | |||
|
|||
- Enhancement: Use the same Python interpreter for `py.text` when `ptw` is run outside of an activated virtual environment. |
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.
s/text/test/ ?!
Also s/py.test/pytest/ then.
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.
Really? |
@blueyed Looks like it's the other way around. @jacebrowning Just curious to hear your rationale. Any specific reason you kept |
return custom.split(' ') | ||
if os.getenv('VIRTUAL_ENV'): | ||
return ('py.test',) | ||
return (sys.executable, '-m', 'pytest') |
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.
Just tested this locally. Got TypeError: can only concatenate tuple (not "list") to tuple
because lists were used outside this function.
I just patched this in f4814f9.
@joeyespo Simply to leave the existing behavior unchanged. I also noticed that pytest-watch prints the full command it's running for pytest, which might introduce some confusing noise to users that were used to seeing a simple "Running py.test" message. |
Why would Maybe it should only fall back to |
@lwm |
I just found this pull request through some searching and was happy to see someone put some time in and decided to show some gratitude! In retrospect, I am glad I also provoked your usual high quality code review 😄. |
My primary use case here is
pipenv
. I would like to be able to do:But this attempts to find a globally installed pytest:
With this change, pytest-watch will call pytest as a module if not currently running in an activated virtual environment. This should also make running pytest-watch globally a nicer experience by ensuring the same Python interpreter is used to run both
ptw
andpy.test
even if the user's shell is misconfigured.