tall-truck-67859
10/22/2021, 11:17 AM12:41:45.93 [ERROR] Completed: Run Pytest - src/python/classify/tests/test_get_model.py failed (exit code 4).
ImportError while loading conftest '/tmp/process-executiondZwPlt/src/python/classify/tests/conftest.py'.
src/python/classify/tests/conftest.py:17: in <module>
from tests.utils.email import get_test_email
E ModuleNotFoundError: No module named 'tests'
I build Classify like this :
cat <<EOT >src/python/classify/BUILD
python_sources(
dependencies=[
"src/python/classify/main.py",
"//:python-multipart",
"//:scikit-learn"
]
)
python_tests(
name="tests",
sources=["tests/*.py"],
dependencies=[
":classify",
"//:pg8000"
]
)
python_distribution(
name="wheel",
dependencies=[":classify"],
provides=setup_py(
name="classify",
version="0.0.0",
),
wheel=True,
)
pex_binary(
name="binary",
entry_point="__main__.py",
dependencies=["//:pg8000"],
)
I use this command to run tests :
- image: recital/classify
custom:
- command: ./pants test src/python/classify/tests:tests
So far I tried everything I thought that could work and I need some help. Thanks !stale-nightfall-29801
10/22/2021, 12:37 PM__init__.py
in your tests directory?tall-truck-67859
10/22/2021, 12:38 PMcurved-television-6568
10/22/2021, 12:53 PM./pants test src/python/classify:tests
curved-television-6568
10/22/2021, 12:54 PMpython_sources
.curved-television-6568
10/22/2021, 12:58 PMtests/*.py
in your python tests target, which is not recursive, so it will not have your test sources from utils/ etc.. for that to work, try sources=["tests/**/*.py"]
might work.tall-truck-67859
10/22/2021, 12:59 PMcurved-television-6568
10/22/2021, 1:00 PMcurved-television-6568
10/22/2021, 1:01 PMtall-truck-67859
10/22/2021, 1:02 PMcurved-television-6568
10/22/2021, 1:06 PM./pants tailor
it will help you create targets in your BUILD files for files that are not already part of any target. See https://www.pantsbuild.org/docs/create-initial-build-filescurved-television-6568
10/22/2021, 1:07 PMenough-analyst-54434
10/22/2021, 1:44 PMsrc/python/classify/tests/conftest.py:17: in <module>
from tests.utils.email import get_test_email
E ModuleNotFoundError: No module named 'tests'
So, then, the question is - what is the X
in the filesystem path X/tests/utils/email.py
and is that X
included in the list printed by ./pants roots
?enough-analyst-54434
10/22/2021, 1:45 PMX
is not in the ./pants roots
list, you'll want to (re?) visit: https://www.pantsbuild.org/docs/source-roots#configuring-source-roots to configure your roots so Pants understands your layout.tall-truck-67859
10/22/2021, 2:44 PMhappy-kitchen-89482
10/22/2021, 3:52 PM