breezy-mouse-20493
04/27/2023, 10:38 PMpants test path/to/test/my_test.py
which depends on a directory of data files. These data files are in the same directory, so I suppose these become a target
. I think I can add these files like so in the BUILD file that lives inside the test
directory:
python_tests(
name="tests",
dependencies=[":mydata"]
)
python_tests(
name="tests0",
files(
name="mydata",
sources=["test-data/*"]
)
So far so good?
๐งต
Edit: The issue was that there were two python_tests
targets. Not sure how this happened. Maybe a pants tailor ::
coupled with an overzealous read of the docs. I'm new to Pants. ๐pants test path/to/test/my_test.py
I get a bunch of failed tests with FileNotFoundError
. Puzzling. I then try to run with the debug flag, and set a breakpoint.
pants test --debug path/to/test/my_test.py
and when I drop into the debugger at a breakpoint, I can use os.listdir
and inspect some files in the sandbox. The files are there, as expected... So I continue. Lots of green tests.enough-analyst-54434
04/27/2023, 10:51 PMbreezy-mouse-20493
04/27/2023, 11:49 PM.
โโโ Root
โโโ myproject
โโโ BUILD
โโโ pyproject.toml
โโโ requirements.txt
โโโ src
โ โโโ mymodule
โ โโโ BUILD
โ โโโ __init__.py
โ โโโ version.py
โโโ test
โโโ BUILD
โโโ test-data
โ โโโ 1573519488933.json
โ โโโ 1573519493613.json
โ โโโ 1573519498213.json
โโโ test_mymodule.py
The BUILD file where I call out the test data is Root/myproject/test/BUILD.python_tests
targets.