better-thailand-42877
03/14/2024, 1:38 PMpants test
. However, when trying pants test governance/app1/test/dataplatform/governance/app1/integration/
, I get ModuleNotFoundError: No module named 'dataplatform.governance.app1.integration.fixtures
. I have seen many questions regarding conftest.py
but could not really understand how to solve this issue? Any help is very appreciated π
βββ app1
β βββ BUILD
β βββ Dockerfile
β βββ main
β β βββ BUILD
β β βββ app.py
β β βββ dataplatform
β β βββ governance
β β βββ app1
β β βββ BUILD
β β βββ client.py
β βββ test
β β βββ BUILD
β β βββ conftest.py
β β βββ dataplatform
β β β βββ governance
β β β βββ app1
β β β βββ integration
β β β β βββ BUILD
β β β β βββ __init__.py
β β β β βββ fixtures
β β β β β βββ BUILD
β β β β β βββ __init__.py
β β β β β βββ client_fixtures.py
β β β β βββ test_integration_client.py
β β β βββ unit
β β β βββ BUILD
β β β βββ __init__.py
β β β βββ test_client.py
app1/test/BUILD
->
python_test_utils(
name="test_utils",
)
app1/test/conftest.py
->
pytest_plugins = [
"dataplatform.governance.app1.integration.fixtures.client_fixtures",
]
pants.toml
->
[source]
root_patterns = [
'main',
'test'
]
little-pilot-11155
03/14/2024, 1:50 PMmain/dataplatform
shadows the test/dataplatform
PYTHONPATH. Try changing test/dataplatform
to test/dataplatform1
and see if that helps.
Generally, you will need to play a bit with a directory layout of your tests as suggested here https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#choosing-a-test-layout-import-rulesbetter-thailand-42877
03/14/2024, 2:58 PMtest/dataplatform1
, it is still failing with
ImportError: Error importing plugin "dataplatform1.governance.app1.integration.fixtures.client_fixtures": No module named 'dataplatform1.governance.app1.integration'
I will have a look at the source you provided.better-van-82973
03/14/2024, 3:10 PMpython_test_utils(
name="test_utils",
dependencies=["app1/test/dataplatform/governance/app1/integration:target"]
)
better-thailand-42877
03/14/2024, 3:23 PMtest/dataplatform1
, I actually succeeded in running the integration tests by adding the dependency explicitly in governance/app1/test/dataplatform1/governance/app1/integration/BUILD
python_tests(
name="tests",
dependencies=[
"//3rdparty/python:reqs",
"//3rdparty/python:reqs0",
"governance/app1/test/dataplatform1/governance/app1/integration/fixtures"
],
)
I will test out your suggestion @better-van-82973 π I guess this would allow me to keep the naming as test/dataplatform
?better-van-82973
03/14/2024, 3:24 PMbetter-thailand-42877
03/14/2024, 3:34 PMtest/dataplatform
directory, is via:
governance/app1/test/BUILD
python_test_utils(
name="test_utils",
dependencies=["governance/app1/test/dataplatform/governance/app1/integration:tests"]
)
Thanks again @little-pilot-11155 and @better-van-82973 βοΈlittle-pilot-11155
03/14/2024, 5:50 PM