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_nameto derive the full test module name, so it will derive the package root based on the presence of__init__.pyfiles 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/testsas the package root, and then/projects/jik/src/jik-app/testsgets added asteststosys.modules, which results in this clashing later when importing fromsrc/uvicorn, astests.utilswill not refer tosrc/uvicorn/tests/utils.py, but tosrc/jik-app/tests/utils.py(which does not exist) due totestsalready being a modu…