Hey - have an odd issue with some tests. I have a ...
# general
p
Hey - have an odd issue with some tests. I have a package called
utils
with an
__init__.py
that looks like this:
Copy code
from .require import require
from .foo import foo

__all__ = ['require', 'foo']
and the
foo.py
and
require.py
files exist and can be imported from other packages as expected (e.g.
import utils.require
). I added a unit test for
foo
which does not use
require
.
require
currently doesn't have any unit tests. My BUILD file is super simple:
Copy code
python_library()

python_tests(name='test')
When I try to run the tests in
utils
I get:
Copy code
E   ModuleNotFoundError: No module named 'utils.require'
My theory is that since I'm not using
require
in any tests that file doesn't get put in my sandbox so it's not available and I therefore get the error. But adding a
dependencies=['./:utils']
to my
python_tests
target doesn't help either. Having an
__init__.py
that exports a bunch of things some of which may not have unit tests seems fairly common so I suspect I'm doing something wrong. Any advice?
h
Hey, check out the tool tip on https://www.pantsbuild.org/docs/python-backend about content in your
__init__.py
files, I suspect that this is the issue We still have a TODO to make the default more sensible
p
that looks like what I was looking for. Thanks!
❤️ 1
h
Pardon the confusion from this gotcha. We've fixed a lot of the gotchas the past few months, but this remains one for sure (Do please continue to share feedback on things like this. Even if you are able to figure it out without asking for help, it is still helpful to share what was confusing. We want Pants to be really seamless to adopt)
p
will do. Thanks for all your work on it. Really enjoying it. As a former Bazel user I can say that I'm liking Pants much better.
🙌 2