-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Running individual test files doesn't work without conftest.py #5785
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
Comments
Duplicate of #2269 |
Hmm, I think you have run into #2269 and interpreted it as a feature. :) I would guess that running Basically, you need a way for your tests to know where to find the It looks like you don't have the 'kids' package installed in your virtualenv. Perhaps it is not even a package. The good practices are to use a virtualenv, make your code a package and install it "editable" in your virtualenv. If that's not feasible, I'd stick with the empty conftest.py or using |
Note that the ModuleNotFoundError is probably the correct behavior here: The current directory isn't necessarily in IMHO, the proper solution is using a virtualenv where you have a development install of your project, and/or tox. edit: @pfctdayelise was faster! |
Would be another good documentation page, "ModuleNotFoundError: the definitive guide to how pytest can find and import your code" |
If you want this to throw an error, shouldn't it also throw an error when That's what's so confusing to me here. How does an empty file explain a change in behavior? There's no configuration I'm doing there, so I don't see why any behavior would change. |
It should, which is why #2269 is open 😉 |
When I try and run an individual test without a
conftest.py
file in the root directory of my project, it appears that it's not loading modules correctly. Here's a screenshot of what I'm doing.The imports at the top of that test are:
I would expect that pytest would have the same functionality without a
conftest.py
file as it would with an emptyconftest.py
file, but that appears not to be the case.The text was updated successfully, but these errors were encountered: