Conftest import error #13945
-
|
Hi, Thanks for the help in advance! Notice that there are multiple conftest.py in the folders with the same name. I have followed the doc's suggestion to add Is there a better way or I did something wrong in the config? (I can't rename the folders as it is a shared project) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Are you sure you added the Maybe try |
Beta Was this translation helpful? Give feedback.
How do you invoke pytest when this error happens?
Also, with
--import-mode=importlibyou might have better luck without some of the__init__.pyfiles.But more generally, such a layout is something that pytest currently doesn't handle. By which I mean, pytest doesn't support the concept of "workspaces"/multiple roots/monorepo layout. It currently assumes that all code is running in the same namespace. So if you have two roots AAA and BBB, both have their own
tests.unit.conftestand pytest can't handle it, it wants just one.It doesn't mean you can't use pytest, just that you can't use a single pytest invocation to test both roots at the same time. You should run
pytest AAAandpytest BBB…