Conftest import error #13945
Answered
by
bluetech
johnmiaoncs
asked this question in
Q&A
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! |
Answered by
bluetech
Nov 12, 2025
Replies: 1 comment 3 replies
|
Are you sure you added the Maybe try |
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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…