-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
pytest has no documented way for the user to point it at local source files. #1937
Comments
Hi, I would say the canonical way is to create a virtual environment and installing your code on it in development mode ( I'm not sure it should be pytest's responsibility to add the test code to |
That makes a lot of sense, thanks. Regardless of what pytest 's responsibilities should be, placing a conftests.py in the root of your project seems to cause it to stick your local project in sys.path. I'd really like to add a mention of this to the documentation, if only because it would have saved me time. It seems like this feature would be useful to people who can't install the codebase under test. Automatically adding modules to sys.path is also the default behavior in nose, so being able to configure pytest that way could help people making the transition from nose to pytest. |
Perhaps what you are seeing here is the default python behavior of adding CWD to |
I have a project installed using Simone Zandara mentions this behavior as a "hidden feature" in their stackoverflow post. |
Thanks for the detailed explanation, I didn't know about this feature myself. 😅 I will try to check later where that happens to confirm that this is a hidden-feature of |
Sounds good, thanks for talking through this with me. I'll draft some documentation changes and make a pull request in a bit so we can get that discussion going. |
Would it be more useful for me to make a pull request to the master branch, or to the reorganize-docs branch? |
|
From the digging I've been doing, it seems like the way to get pytest to add your local code to sys.path is to place a conftets.py and pytests.ini file in the base directory of your project. Since I haven't been able to find a mention of this in the documentation I'm hoping a dev can shed some light on whether this is a supported feature or not, and if there's a more canonical way of doing it.
Relevant SO posts:
http://stackoverflow.com/questions/34466027/in-py-test-what-is-the-use-of-conftest-py-files
http://stackoverflow.com/questions/39499937/is-there-a-standard-way-to-tell-py-test-to-run-against-specific-code
The text was updated successfully, but these errors were encountered: