Replies: 2 comments
-
Is there a reason why you want to put (though it is mentioned in the Good Integration Practices section of the pytest documentation) |
Beta Was this translation helpful? Give feedback.
-
After digging around a bit, I found that the root dir in pytest is indeed defined by the location of pyproject.toml or other ini files, if they exist. So while the location of |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I encountered an odd issue in my python project.
Where adding a "pyproject.toml" file somewhere in the project makes pytest unable to set the correct 'root module'.
I made the following minimal reproductible example :
We have top level module
src
, containing the moduleprogram
that we want to test.The tests for
program
are located inprogram/tests
In
conftest.py
we have:Simulating the fact that the tests will import symbols from the code they are testing.
When I run
python -m pytest --import-mode=importlib src/program
Everything is fine :)
But when I add a
pyproject.toml
to myprogram
project:Things don't work out anymore (here the pyproject.toml is empty, but I've tried with semantically correct ones too).
I get this
ImportError
I have this error with versions
8.3.5
and8.5.3
, did not test any other version.I think this might not be a bug, just that pytest is doing something to determine what is the top-level package, and that the presence of a pyproject mess that up.
Could someone tell me if there is any way to make this works?
My curent getaround is deleting the pyproject.toml from the filesystem just before running pytest...
Beta Was this translation helpful? Give feedback.
All reactions