Details
-
Type:
RFC
-
Status: Implemented
-
Resolution: Done
-
Component/s: DM
-
Labels:None
Description
Our Python unit tests are executed via the pytest utility in all circumstances except manual execution during development. In that last case, we still allow python tests/test_foo.py via the underlying unittest infrastructure.
pytest has many features that extend testing capabilities beyond what unittest provides. One example that has come up recently (in DM-31141) is parametrizing tests; pytest provides facilities for doing this, while we have had to invent our own ways of doing so on top of unittest.
pytest is always a part of our development environment, as it is included in rubin-env.
Accordingly, I propose that we allow the use of pytest-only features in Python unit tests, which will break the usage of python tests/test_foo.py, forcing the use of pytest tests/test_foo.py instead. python -m pdb tests/test_foo.py can be replaced by pytest --pdb tests/test_foo.py (to debug on failure) or pytest --trace tests/test_foo.py (to debug at the start of each test).
This is not a mandate to use pytest style or to remove unittest from our tests. We are not changing our other unittest-based extensions such as open-file-leak or specialized assertions at this time. Most developers should not need to change what they are doing at all. But where appropriate pytest functionality exists to extend our typical usage, this proposal would allow it.
+1