pytest cannot find Module due to similar package name in dependencies

Viewed 32

I started with Python a month back and I am working on a Python project with below package structure:

  • Package in project: "xyz.a.b.c.d"
  • Package of dependent modules: "xyz.a.b.c" and "xyz.a.b.e"

While running tests using pytest, I get a ModuleNotFoundError: No module named 'xyz.a.b.c.d'. When I add __init__ to each of the folders i.e. xyz, a, b and c (d already has a __init__) then ModuleNotFoundError: No module named 'xyz.a.b.e'

How do I go about resolving this?

UPDATE: There was a __init__.py inside "xyz.a.b.c" after removing which the issue is resolved. Wondering if while running pytest, due to init, the dependencies hides any sub package from dependent project or other libraries?

0 Answers
Related