Question regarding --import-mode=importlib
#12714
-
I have this project layout:
On As far as I understand, So... I'm a bit confused why the first If I add |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 13 replies
-
Hi @Kludex Is that reproducible in a MWE? I ask because some things are omitted from the post, for example if there are |
Beta Was this translation helpful? Give feedback.
Hi @Kludex finally found the time to investigate a bit more.
Actually pytest will use
resolve_pkg_root_and_module_name
to derive the full test module name, so it will derive the package root based on the presence of__init__.py
files on the file's directory and upwards.In your example, for
/projects/jik/src/jik-app/tests/test_app.py
, it finds/projects/jik/src/jik-app/tests
as the package root, and then/projects/jik/src/jik-app/tests
gets added astests
tosys.modules
, which results in this clashing later when importing fromsrc/uvicorn
, astests.utils
will not refer tosrc/uvicorn/tests/utils.py
, but tosrc/jik-app/tests/utils.py
(which does not exist) due totests
already being a modu…