fresh-cat-90827
05/27/2022, 10:30 AMpytest
when using the --ignore
option (of pytest
)? Or does one need to pass the path to the directory differently when run with Pants?fresh-cat-90827
05/27/2022, 10:30 AMdiff --git a/helloworld/greet/greeting_test.py b/helloworld/greet/greeting_test.py
index 8d43373..2a564f0 100644
--- a/helloworld/greet/greeting_test.py
+++ b/helloworld/greet/greeting_test.py
@@ -5,5 +5,6 @@ from helloworld.greet.greeting import Greeter
def test_greeter() -> None:
+ assert False
greeter = Greeter(translations={"hello": {"es": "hola"}})
assert greeter.greet("test") == "Hola, test!"
Checkout https://github.com/pantsbuild/example-python.git, run
$ pytest --ignore="helloworld/greet"
======================================================================================================== test session starts ========================================================================================================
platform darwin -- Python 3.9.12, pytest-7.0.1, pluggy-1.0.0
rootdir: /Users/user/code/PantsBuild/example-python
collected 3 items
helloworld/translator/translator_test.py ... [100%]
========================================================================================================= 3 passed in 0.02s =========================================================================================================
Then run with Pants:
$ ./pants test :: --test-force -- --ignore="helloworld/greet"
./pants test :: --test-force -- --ignore="helloworld/greet"
11:25:13.17 [INFO] Completed: Run Pytest - helloworld/translator/translator_test.py:tests succeeded.
11:25:13.27 [ERROR] Completed: Run Pytest - helloworld/greet/greeting_test.py:tests failed (exit code 1).
============================= test session starts ==============================
platform darwin -- Python 3.8.2, pytest-7.0.1, pluggy-1.0.0
rootdir: /private/var/folders/k0/3nssm8v15r5b08k1k1wyhs2r0000gp/T/process-executionOeZbEu
plugins: cov-3.0.0
collected 1 item
helloworld/greet/greeting_test.py F [100%]
=================================== FAILURES ===================================
_________________________________ test_greeter _________________________________
def test_greeter() -> None:
> assert False
E assert False
helloworld/greet/greeting_test.py:8: AssertionError
- generated xml file: /private/var/folders/k0/3nssm8v15r5b08k1k1wyhs2r0000gp/T/process-executionOeZbEu/helloworld.greet.greeting_test.py.tests.xml -
=========================== short test summary info ============================
FAILED helloworld/greet/greeting_test.py::test_greeter - assert False
============================== 1 failed in 0.24s ===============================
✓ helloworld/translator/translator_test.py:tests succeeded in 1.12s.
✕ helloworld/greet/greeting_test.py:tests failed in 1.24s.
The tests in the greet
directory are still run. I expect them to be ignored.bitter-ability-32190
05/27/2022, 11:47 AMblack
has force exclude (so when your editor tells black to format CLI file doesn't win).bitter-ability-32190
05/27/2022, 11:48 AMfresh-cat-90827
05/27/2022, 11:53 AMfresh-cat-90827
05/27/2022, 1:56 PM--ignore
(and other options) may interfere with how Pants gets the tests to run?hundreds-father-404
05/27/2022, 1:59 PMskip_tests
field: https://www.pantsbuild.org/docs/reference-python_tests#codeskip_testscodefresh-cat-90827
05/27/2022, 1:59 PMhundreds-father-404
05/27/2022, 2:00 PMdo you think it would be helpful if I extend the docsmaybe a small "warning" info box? Saying that
--ignore
doesn't work. Instead use skip_test
fieldfresh-cat-90827
05/27/2022, 2:00 PMtests/**/*
and underneath there is a directory I’d like quickly to exclude, I’d need to create a BUILD
file in that directory?hundreds-father-404
05/27/2022, 2:19 PMoverrides
python_tests(
sources=["tests/**/*_test.py"],
overrides={
"tests/dir/*_test.py": {"skip_tests": True},
},
)
fresh-cat-90827
05/27/2022, 2:22 PMbitter-ability-32190
05/27/2022, 2:42 PMmaybe a small "warning" info box? Saying thatIf we do this, we shouldn't word it so strongly. At some pointdoesn't work. Instead use--ignore
fieldskip_test
pytest
might prefer the flag ignore over specified files, and we don't control the pytest version.