We recently adopted two RFCs that improve how we manage Python unit test modules. I’ve created a Confluence page to help us track the implementation of these RFCs across the stack (similar to how we managed other Pytest and Python 3 migrations in the past).
RFC-215 states that Python unit test modules should not be executable (that is
./test_mymodule.py shouldn’t run, but of course “python test_mymodule.py” should). To implement this RFC:
- Remove the executable flag from Python test modules (e.g.,
chmod -x ...).
- Remove the hash-bang line from Python test modules.
RFC-229 states that Python unit test modules should be named with a
test_ prefix to enable automatic discovery by pytest. For example,
tests/testMyModule.py should be renamed to
This is documented in the Python Unit Testing guide.
As you work on a package, take a look at the Confluence page. If no one has committed to migrating the package, add you name to the list. Once the work is merged to master you can check the package off the list.
I anticipate that this migration can be done as a commit at the beginning of other ticketed work.