purple-umbrella-89891
09/07/2022, 8:01 AMmypkg/
subpkg1/
__init__.py
subpkg2/
__init__.py
Notice the missing __init__.py under mypkg , which makes it an implicit namespace package (PEP-420). Now the test I wrote looks like this:
# tests/test_namespace.py
import mypkg
def test_namespace():
assert mypkg.__file__ is None
While this test runs successfully in pytest, it fails in the hermetic environment of pants, because the dependency on mypkg does not include any files. The directory mypkg itself is not created in the local environment, so mypkg is not importable.
I know there are a couple of trivial solutions to this (import mypkg.subpkg1 in the test, specifying a dependency manually or checking for the absence of mypkg/__init__.py in pre-commit hooks), but is there any solution in pants that I'm missing, e.g. some configuration option?enough-analyst-54434
09/07/2022, 2:22 PMpython_distribution s (assuming there are such things in your repo) and then checking those all have a PEP-420 implicit ns package by whatever means up to just actually extracting or installing them in a venv and checking the layout.