https://pantsbuild.org/ logo
#general
Title
# general
f

full-toothbrush-75676

09/16/2021, 12:25 AM
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

hundreds-father-404

09/16/2021, 12:29 AM
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

full-toothbrush-75676

09/16/2021, 12:31 AM
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

hundreds-father-404

09/16/2021, 12:42 AM
Great! Let us know if you have any other questions or feedback 🙂
👍 1
2 Views