dazzling-diamond-4749
11/18/2021, 6:14 AM2.8.0
and I'm running into some trouble with conftest
My conftest would complain about missing module, if I run ./pants test path/to/my/test.py:tests
But when I run the same target in ./pants repl path/to/my/test.py:tests
and import the same missing module, python is able to find the module.dazzling-diamond-4749
11/18/2021, 6:16 AMproject/test/python/package/conftest.py
and the BUILD looks like
python_test_utils()
python_tests(
name="tests0",
dependencies=[
stuff...
],
)
the test is in project/test/python/package/sub_pkg/test.py
the BUILD looks like
python_tests(
name="tests",
)
hundreds-father-404
11/18/2021, 6:31 AMdazzling-diamond-4749
11/18/2021, 6:51 AMpython_sources
can infer deps?dazzling-diamond-4749
11/18/2021, 7:09 AMā pynest git:(rmeng/pants28-round2) ā ./pants test ml/cbml/test/python/cbml/util/test_sql_parser.py:tests
23:07:00.84 [ERROR] Completed: Run Pytest - ml/cbml/test/python/cbml/util/test_sql_parser.py:tests failed (exit code 4).
ImportError while loading conftest '/private/var/folders/28/6tcr0h8j1b3485bqvp8pwr6m0000gp/T/process-executionmerCJe/ml/cbml/test/python/cbml/conftest.py'.
ml/cbml/test/python/cbml/conftest.py:17: in <module>
from cbml.dataio.loading import load_sql
E ModuleNotFoundError: No module named 'cbml.dataio'
š ml/cbml/test/python/cbml/util/test_sql_parser.py:tests failed.
ā pynest git:(rmeng/pants28-round2) ā ./pants filedeps --transitive ml/cbml/test/python/cbml/util/test_sql_parser.py:tests | grep ml/cbml/src/python/cbml/dataio
ml/cbml/src/python/cbml/dataio/BUILD
ml/cbml/src/python/cbml/dataio/emr.py
ml/cbml/src/python/cbml/dataio/loading.py
ml/cbml/src/python/cbml/dataio/s3.py
ml/cbml/src/python/cbml/dataio/snowflake.py
ml/cbml/src/python/cbml/dataio/tarutil.py
ā pynest git:(rmeng/pants28-round2) ā ./pants filedeps --transitive ml/cbml/test/python/cbml:utils | grep ml/cbml/src/python/cbml/dataio
ml/cbml/src/python/cbml/dataio/BUILD
ml/cbml/src/python/cbml/dataio/emr.py
ml/cbml/src/python/cbml/dataio/loading.py
ml/cbml/src/python/cbml/dataio/s3.py
ml/cbml/src/python/cbml/dataio/snowflake.py
ml/cbml/src/python/cbml/dataio/tarutil.py
Maybe conftest loading has some quirks? Like run before path is setup?dazzling-diamond-4749
11/18/2021, 7:11 AM__init__.py
isn't getting picked up some how, but it's empty anywayshundreds-father-404
11/18/2021, 8:29 AMhundreds-father-404
11/18/2021, 8:30 AMdazzling-diamond-4749
11/18/2021, 7:27 PMhundreds-father-404
11/18/2021, 7:30 PMconftest.py
in a python_tests
target. We only changed the default
For now, comment out the python_test_utils
target and explicitly set sources=["conftest.py", "*_test.py"]
on your python_tests
target (or whatever the relevant globs are)dazzling-diamond-4749
11/18/2021, 9:00 PMtest_*
. Maybe it's python_test_utils
picking up tests causing pants to get confuseddazzling-diamond-4749
11/18/2021, 9:00 PMdazzling-diamond-4749
11/18/2021, 10:06 PMpython_test_utils(
sources=["conftest.py"],
)
python_tests(
name="tests0",
dependencies=[
stuff...
],
)
and
python_tests(
name="tests0",
sources=["conftest.py", "test_*"],
dependencies=[
stuff...
],
)
neither worked šhundreds-father-404
11/18/2021, 10:07 PMdazzling-diamond-4749
11/18/2021, 10:08 PM