freezing-fall-2672
09/01/2023, 3:01 PMexample-django
repository this snippet:
python_test_utils(
name="test_utils",
)
is effectively dead code?
at least I can't find anywhere something like this:
python_test_utils(
name="test_utils",
sources=["some_test_utils.py"],
)
I'm still really new so maybe I just didn't get things yet 𤷠https://github.com/pantsbuild/example-djangoenough-analyst-54434
09/01/2023, 3:04 PMsources
field I linked to, but read the default value.enough-analyst-54434
09/01/2023, 3:06 PMpython_test_utils(name="test_utils")
down in a BUILD file at all, but unfortunately you do, perhaps leading to more confusion than necessary.enough-analyst-54434
09/01/2023, 3:07 PMenough-analyst-54434
09/01/2023, 3:08 PMpants filedeps <target>
for example.freezing-fall-2672
09/01/2023, 3:09 PM*.pyi
file ... is this a typo or something new to me?
default: ('conftest.py', 'test_*.pyi', '*_test.pyi', 'tests.pyi')
enough-analyst-54434
09/01/2023, 3:09 PMenough-analyst-54434
09/01/2023, 3:09 PMfreezing-fall-2672
09/01/2023, 3:09 PMi
??enough-analyst-54434
09/01/2023, 3:09 PMfreezing-fall-2672
09/01/2023, 3:09 PMenough-analyst-54434
09/01/2023, 3:09 PMfreezing-fall-2672
09/01/2023, 3:10 PMenough-analyst-54434
09/01/2023, 3:10 PMfreezing-fall-2672
09/01/2023, 3:11 PMfreezing-fall-2672
09/01/2023, 3:11 PMfreezing-fall-2672
09/01/2023, 3:11 PMfreezing-fall-2672
09/01/2023, 3:12 PMenough-analyst-54434
09/01/2023, 3:14 PMfreezing-fall-2672
09/01/2023, 3:14 PMenough-analyst-54434
09/01/2023, 3:14 PMfreezing-fall-2672
09/01/2023, 3:15 PMenough-analyst-54434
09/01/2023, 3:15 PMfreezing-fall-2672
09/01/2023, 3:15 PMenough-analyst-54434
09/01/2023, 3:16 PMfreezing-fall-2672
09/01/2023, 3:16 PMenough-analyst-54434
09/01/2023, 3:16 PMenough-analyst-54434
09/01/2023, 3:17 PMpants tailor
generate throw-away BUILD files like the one you pointed out.enough-analyst-54434
09/01/2023, 3:17 PMfreezing-fall-2672
09/01/2023, 3:18 PMfreezing-fall-2672
09/01/2023, 3:19 PMAh, gotcha. It looks like Pantsbuild has evolved a bit since my last update. The python_test_utils target generator seems more flexible now, and it appears to have a default for the sources field set to common test utility filenames like conftest.py, test_*.pyi, etc.
Key Takeaways:
Flexible Source Defaults: The sources field has a default value set to include commonly used test utility filenames.
Overrides: You can override specific settings for individual source files that this target generates.
Linting and Type Checking: You can skip various linting and type checking processes per target, providing a lot of control over your code quality checks.
Looks like it's a more robust and feature-rich utility than I initially thought. The lack of explicit sources in your BUILD files now makes sense; Pants is inferring them based on the defaults.
enough-analyst-54434
09/01/2023, 3:20 PMfreezing-fall-2672
09/01/2023, 3:21 PMfreezing-fall-2672
09/01/2023, 3:26 PMpython_test_utils
in the BUILD file, pants loads the conftest.py file for each test - when it's relevant?
so each app module has its own conftest.py because of this?
... would this mean that by default pants disables the default behaviour of pytest to load a conftest.py file and with above it's enabled again or is pytest itself not affected by this?enough-analyst-54434
09/01/2023, 3:29 PMpants run
goal). It copies all needed files and only the needed files over to a sandbox directory and runs there.enough-analyst-54434
09/01/2023, 3:30 PMenough-analyst-54434
09/01/2023, 3:30 PMfreezing-fall-2672
09/01/2023, 3:31 PMenough-analyst-54434
09/01/2023, 3:32 PMfreezing-fall-2672
09/01/2023, 3:32 PMfreezing-fall-2672
09/01/2023, 3:33 PMenough-analyst-54434
09/01/2023, 3:33 PMfreezing-fall-2672
09/01/2023, 3:35 PMenough-analyst-54434
09/01/2023, 3:36 PMfreezing-fall-2672
09/01/2023, 3:36 PMenough-analyst-54434
09/01/2023, 3:36 PMfreezing-fall-2672
09/01/2023, 3:36 PMfreezing-fall-2672
09/01/2023, 3:39 PMfreezing-fall-2672
09/01/2023, 3:40 PMhappy-kitchen-89482
09/01/2023, 3:56 PM... would this mean that by default pants disables the default behaviour of pytest to load a conftest.py file and with above it's enabled again or is pytest itself not affected by this?This is about which files get placed in the sandbox. Currently due to the legacy behavior, those files have to be wrapped by these BUILD file targets, even if they are trivial. Pytest will always try and load conftest.py, but it won't find it unless Pants places it in the sandbox, which it requires this BUILD file stanza to do.
happy-kitchen-89482
09/01/2023, 3:56 PMfreezing-fall-2672
09/01/2023, 3:57 PMhappy-kitchen-89482
09/01/2023, 3:57 PMfreezing-fall-2672
09/01/2023, 3:58 PMfreezing-fall-2672
09/01/2023, 3:59 PMhappy-kitchen-89482
09/01/2023, 4:04 PMhappy-kitchen-89482
09/01/2023, 4:05 PMfreezing-fall-2672
09/01/2023, 4:06 PMfreezing-fall-2672
09/01/2023, 4:07 PMhappy-kitchen-89482
09/01/2023, 4:14 PM