clever-hamburger-59716
09/28/2022, 3:12 PMresources (
name="test-data",
sources=["./examples/data/*"],
)
pex_binary(
name="service",
entry_point="service.py",
platforms=[
"current",
"manylinux2014-x86_64-cp-39-cp39",
],
dependencies=[":test-data"],
)
test/sub_dir_2/BUILD has this:
pex_binary(
name="test_service",
entry_point="test_service.py",
dependencies=["service:test-data"],
)
I am trying to package everything as a pex file. A test in test_service.py uses the files as such:
path = str(pathlib.Path(__file__, "../../../examples/data/data.csv").resolve())
do_something_with(path)
Checking the sandbox, indeed, the files don't exist(actually no resources exist). However, I do see the files in the packaged .pex archives.
I am trying to run the test as such
./pants --keep-sandboxes=on_failure test service/test/sub_dir_2/test_service.py -- -k test_csv
I am using pants 2.13.0. I would really appreciate any pointers on how to go about including files in tests.
TIA,
CSNhappy-kitchen-89482
09/28/2022, 5:30 PMservice.py
, rather than to the pex_binarypex_binary
to represent tests is unusual. Any reason you’re not using python_tests
?clever-hamburger-59716
09/28/2022, 11:44 PMpython_tests(
name="tests",
sources=["test_service.py"],
dependencies=["service:test-data"],
)
python_sources()
pex_binary(
name="test_service",
entry_point="test_service.py",
)
Thank you so much for the help!
qq: Is there a way to force pants to rerun the tests? I wanna experiment a bit with my setup and pants returns the memoized results.happy-kitchen-89482
09/29/2022, 12:09 AMtest_service.py
has an if __name__ == '__main__'
stanza in it? That will cause tailor
to guess that it’s a binary and generate a pex_binary
target for it.pytest
, or as a binary?clever-hamburger-59716
09/29/2022, 1:08 AMhappy-kitchen-89482
09/29/2022, 1:16 AMclever-hamburger-59716
09/29/2022, 1:35 AMhappy-kitchen-89482
09/29/2022, 2:16 AMclever-hamburger-59716
09/29/2022, 4:07 AMhappy-kitchen-89482
10/12/2022, 6:57 PM