Hi all! Is there a way to override the default `py...
# general
f
Hi all! Is there a way to override the default
pytest
naming conventions? I’ve tried adding a
pytest.ini
overriding the global test file naming convention to
*_test.py
but pants is still picking up a file named
test_case.py
. I may be missing something obvious 🤔
h
Hi! Yes, you would explicitly set the
sources
field for the
python_tests
target in that directory to something like
["*_test.py"]
It sounds like
test_case.py
is a util file, not a test file? If so, then you want to include it in the
python_library
target for that directory, so update its
sources
field to be
["*.py", "!*_test.py"]
, meaning all Python files but the test files
Copy code
python_library(sources=["*.py", "!*_test.py"])
python_tests(name="tests", sources=["*_test.py"])
🙌 1
f
test_case.py
is a util file, used in tests, yes! Ahh I see, got it – that makes sense! I’ll give that a try. Thanks!
❤️ 1
that did the trick 👍 tyty!
h
Great! Let us know if you have any other questions or feedback 🙂
👍 1