freezing-fall-2672
09/04/2023, 6:12 AM.
├── service_a
│ ├── app_a
│ │ └── tests
│ │ └── test_a.py
│ ├── app_b
│ │ └── tests
│ │ └── test_b.py
│ ├── app_c
│ │ └── tests
│ │ └── test_c.py
│ ├── manage.py
│ ├── requirements.txt
│ └── service_a
│ └── settings.py
├── service_b
│ ├── app_a
│ │ └── tests
│ │ └── test_a.py
│ ├── app_b
│ │ └── tests
│ │ └── test_b.py
│ ├── app_c
│ │ └── tests
│ │ └── test_c.py
│ ├── manage.py
│ ├── requirements.txt
│ └── service_b
│ └── settings.py
└── util
└── settings_for_tests.py
https://app.warp.dev/block/NorDRW8zy6JkoCo1Z8VmE7
the difference to the django example is:
1. multiple apps pro service
2. tests in a submodule
now I struggle to provide enough meta data to pants to make tests work, with all different kind of approaches.
I'm more than willing to also create a little example repo out of this - is anyone willing to help and or interested in joining forces?acoustic-library-86413
09/04/2023, 6:54 AMfreezing-fall-2672
09/04/2023, 7:15 AMfreezing-fall-2672
09/04/2023, 9:24 AMpants test edmmp/service_a/app_a/tests/test_views.py
11:21:47.31 [INFO] Initializing scheduler...
11:21:49.94 [INFO] Scheduler initialized.
11:21:49.98 [WARN] Pants cannot infer owners for the following imports in the target edmmp/service_a/conftest.py:test_utils:
* edmmp.util.settings_for_tests.configure_settings (line: 4)
If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see <https://www.pantsbuild.org/v2.17/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
11:21:51.59 [WARN] Failed to generate JUnit XML data for edmmp/service_a/app_a/tests/test_views.py.
11:21:51.59 [ERROR] Completed: Run Pytest - edmmp/service_a/app_a/tests/test_views.py - failed (exit code 4).
ImportError while loading conftest '/private/var/folders/ll/98hnvg_n5l3by0224q_qybc40000gn/T/pants-sandbox-RLtdW4/edmmp/service_a/conftest.py'.
edmmp/service_a/conftest.py:4: in <module>
from edmmp.util.settings_for_tests import configure_settings
E ModuleNotFoundError: No module named 'edmmp'
✕ edmmp/service_a/app_a/tests/test_views.py failed in 0.32s.
so it's about no module named 'edmmp'
which is the equivalent to helloworld
in the django example repository.freezing-fall-2672
09/04/2023, 9:27 AMedmmp
to a python module (with adding a ___init___.py
file) and changing to root_patterns=['*']
in pants.tomlfreezing-fall-2672
09/04/2023, 9:39 AMgreet
and person
) are outside of the actual django instances then, which are in service
freezing-fall-2672
09/04/2023, 9:40 AMacoustic-library-86413
09/04/2023, 9:50 AMpants dependencies
on the test file in question to see what dependencies pants has inferred automatically. I suspect the source code is not being pulled in because your tests have no explicit dependencies on the routes you're calling.
In the BUILD file next to the tests:
python_tests(dependencies=["/path/to/file/with/api_endpoint_logic.py"])
I've never used Django with Pants so I don't know if they have an integration to automatically determine which routes are used based on Regex, but I suspect they don't. As a result you need to tell pants which fil e response = self.client.get("/app_a/")
will ultimately call.freezing-fall-2672
09/04/2023, 10:18 AMfreezing-fall-2672
09/04/2023, 11:13 AMpants dependencies --transitive edmmp/service_a/app_a/test_views.py
3rdparty/python/edmmp-lock.txt:_edmmp_lockfile
edmmp/service_a/conftest.py:test_utils
edmmp/service_a/requirements.txt:reqs
edmmp/service_a:reqs#django
edmmp/util/settings_for_tests.py
and
pants test edmmp/service_a/app_a/test_views.py
13:21:01.83 [INFO] Completed: Building pytest.pex
13:21:01.84 [ERROR] 1 Exception encountered:
Engine traceback:
in `test` goal
ProcessExecutionFailure: Process 'Building pytest.pex' failed with exit code 1.
stdout:
stderr:
Could not find script 'pytest' in any distribution within PEX!
Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
freezing-fall-2672
09/04/2023, 11:20 AMfreezing-fall-2672
09/04/2023, 11:24 AMrefined-addition-53644
09/04/2023, 12:33 PMfrom edmmp import ..
Your source root should have.
root_patterns = ["/"]
freezing-fall-2672
09/04/2023, 12:51 PMfreezing-fall-2672
09/04/2023, 1:03 PMfreezing-fall-2672
09/04/2023, 1:04 PM