modern-wolf-36228
10/21/2021, 9:54 AMmodern-wolf-36228
10/21/2021, 9:56 AMpython_sources(
dependencies=[
"src/python/authenticator/resources",
"src/python/authenticator/main.py",
"//:python-multipart",
"//:asyncpg"
]
)
python_tests(
name="tests",
timeout=120,
sources=["tests/conftest.py"],
dependencies=["src/python/authenticator/tests.py"],
extra_env_vars=[
"PROJECT_NAME=authenticator",
]
)
pex_binary(
name="binary",
entry_point="__main__.py",
dependencies=["//:asyncpg"],
)
curved-television-6568
10/21/2021, 9:59 AMmodern-wolf-36228
10/21/2021, 10:00 AMmodern-wolf-36228
10/21/2021, 10:01 AMcurved-television-6568
10/21/2021, 10:02 AMhappy-kitchen-89482
10/21/2021, 2:38 PMhappy-kitchen-89482
10/21/2021, 2:38 PMhappy-kitchen-89482
10/21/2021, 2:46 PMpython_tests(
name="tests",
timeout=120,
sources=["tests/conftest.py"],
dependencies=["src/python/authenticator/tests.py"],
extra_env_vars=[
"PROJECT_NAME=authenticator",
]
)
Whereas you want the test files in sources
of python_tests
targets , not in dependencies
happy-kitchen-89482
10/21/2021, 2:46 PMsrc/python/authenticator
?tall-truck-67859
10/21/2021, 3:24 PMpython_tests
inside tests/BUILD file, and remove tests files from dependencies yes 🙂hundreds-father-404
10/21/2021, 3:25 PMcurved-television-6568
10/22/2021, 7:09 AMpublish
for a docker_image
target, and that target has a skip_push
. So the target isn’t off.. it’s just that it wasn’t applicable for the requested goal.happy-kitchen-89482
10/22/2021, 4:50 PMhappy-kitchen-89482
10/22/2021, 4:50 PMhundreds-father-404
10/22/2021, 4:51 PMhappy-kitchen-89482
10/22/2021, 5:04 PMhappy-kitchen-89482
10/22/2021, 5:05 PMconftest.py
in there even explicitlyhundreds-father-404
10/22/2021, 5:07 PMconftest.py
and foo_test.pyi
are test utils, they're not tests themselves. What does timeout
field mean on a type stub?hundreds-father-404
10/22/2021, 5:09 PMopt_out
hack
The world is different now, with ./pants tailor
making the boilerplate less offensive, python_tests
vs python_test
targets + ./pants peek
making the weirdness more explicit, and multiple user lockfiles meaning this bad modeling is actually going to cause issueshappy-kitchen-89482
10/23/2021, 6:17 PMhappy-kitchen-89482
10/23/2021, 6:18 PMconftest.py
(maybe it tests conf.py
...)happy-kitchen-89482
10/23/2021, 6:18 PMhappy-kitchen-89482
10/23/2021, 6:19 PMfoo.py
in python_sources when it does contain tests.happy-kitchen-89482
10/23/2021, 6:19 PMhappy-kitchen-89482
10/23/2021, 6:19 PMhappy-kitchen-89482
10/23/2021, 6:20 PMhappy-kitchen-89482
10/23/2021, 6:20 PMhappy-kitchen-89482
10/23/2021, 6:20 PMhappy-kitchen-89482
10/23/2021, 6:20 PMhundreds-father-404
10/23/2021, 6:33 PMconftest.py
- that particular file name is already very very special-cased
And then for type stubs like test_foo.pyi
, it never really makes sense to run Pytest on a type stub file
Those are the only two restrictions we put on python_tests
. You could still put foo.py
in it if you'd likehappy-kitchen-89482
10/23/2021, 11:43 PMhappy-kitchen-89482
10/23/2021, 11:44 PMhappy-kitchen-89482
10/23/2021, 11:45 PMhappy-kitchen-89482
10/23/2021, 11:46 PMhundreds-father-404
10/24/2021, 12:14 AM.py
or no file extension. We error on .js
, even though it's possible to run Black on .js
files:
❯ black foo.js
All done! :sparkles: :cake: :sparkles:
1 file left unchanged.
That is, generally, we already are doing some eager validation for cases that are legal, but very unlikely to be what the user intended so that we can instead give helpful instructions towards what they likely wanted to do
offered no escape hatchThe escape hatch is to name it literally anything other than
conftest.py
! Like conf_test.py
happy-kitchen-89482
10/24/2021, 8:55 PM