clever-hamburger-5971609/28/2022, 3:12 PM
test/sub_dir_2/BUILD has this:
resources ( 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"], )
I am trying to package everything as a pex file. A test in test_service.py uses the files as such:
pex_binary( name="test_service", entry_point="test_service.py", dependencies=["service:test-data"], )
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
path = str(pathlib.Path(__file__, "../../../examples/data/data.csv").resolve()) do_something_with(path)
I am using pants 2.13.0. I would really appreciate any pointers on how to go about including files in tests. TIA, CSN
./pants --keep-sandboxes=on_failure test service/test/sub_dir_2/test_service.py -- -k test_csv
happy-kitchen-8948209/28/2022, 5:30 PM
, rather than to the pex_binary
to represent tests is unusual. Any reason you’re not using
clever-hamburger-5971609/28/2022, 11:44 PM
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.
python_tests( name="tests", sources=["test_service.py"], dependencies=["service:test-data"], ) python_sources() pex_binary( name="test_service", entry_point="test_service.py", )
happy-kitchen-8948209/29/2022, 12:09 AM
stanza in it? That will cause
if __name__ == '__main__'
to guess that it’s a binary and generate a
target for it.
, or as a binary?
clever-hamburger-5971609/29/2022, 1:08 AM
happy-kitchen-8948209/29/2022, 1:16 AM
clever-hamburger-5971609/29/2022, 1:35 AM
happy-kitchen-8948209/29/2022, 2:16 AM
clever-hamburger-5971609/29/2022, 4:07 AM
happy-kitchen-8948210/12/2022, 6:57 PM