Skip to content
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

Allow pytest to be invoked as a module #7207

Closed
thirtytwobits opened this issue Sep 5, 2019 · 6 comments
Closed

Allow pytest to be invoked as a module #7207

thirtytwobits opened this issue Sep 5, 2019 · 6 comments
Assignees
Labels
area-testing feature-request Request for new features or functionality info-needed Issue requires more information from poster

Comments

@thirtytwobits
Copy link

I have tests in my Python project (Nunavut) that use a shared fixture that requires the "test" directory be on the sys path. Our tox scripts invoke pytest like thus:

pip install -e .
cd test
python -m pytest

Which ensures that test/fixtures gets added to the sys path. Can we add a feature to allow the test discovery and execution panel to invoke pytest (or other test modules) as a module starting from the cwd (where cwd is configurable as python.testing.cwd? So this would have the same effect as:

cd ${python.testing.cwd}
${python.pythonPath} -m pytest ${python.testing.pytestArgs}

Either that or allow .env files to set PYTHONPATH which doesn't seem to work either. As it stands there doesn't seem to be a way to run the pytests for https://github.com/UAVCAN/nunavut in vscode without manually setting up a task.

@thirtytwobits thirtytwobits added triage-needed Needs assignment to the proper sub-team feature-request Request for new features or functionality labels Sep 5, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 5, 2019
@kimadeline
Copy link

kimadeline commented Sep 6, 2019

Hello @thirtytwobits 👋 Thank you for reaching out!

Are you referring to #7210 here:

allow .env files to set PYTHONPATH which doesn't seem to work either.

The pytest documentation suggests using a conftest.py file for directory fixtures. When adding it after cloning https://github.com/UAVCAN/nunavut I could discover and run the tests without a task or setting PYTHONPATH:

image

In any case, this issue is now marked as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes your idea gets to help us make our decision.

@thirtytwobits
Copy link
Author

Hmm. I'm on a macintosh and I am always using an active virtualenv. I wonder if this is problem either specific to my platform or to code sessions using a virtualenv? I'll try the conftest.py solution to see if that helps.

@thirtytwobits
Copy link
Author

conftest.py doesn't help me. Thanks though. #7210 getting fixed would provide a solution though.

@kimadeline
Copy link

That's pretty strange, because I'm on macOS too and conftest.py was enough 🤔 although I'm using venv instead of virtualenv. #7210 got merged and should be available in the next release, you can downgrade to an older version of the extension meanwhile if necessary.

@luabud
Copy link
Member

luabud commented Nov 1, 2019

The extension already allows pytest to be invoked as a module, as long as you don't specify pytestPath. @thirtytwobits Do you still have the issue regarding environment variables?

@luabud luabud added info-needed Issue requires more information from poster and removed needs decision labels Nov 1, 2019
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Nov 1, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Nov 4, 2019
@brettcannon
Copy link
Member

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.

@ghost ghost removed the triage label Jan 8, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing feature-request Request for new features or functionality info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

5 participants