This is a first step towards fully eliminating the test.sh shell script. pytest is a nice testing framework with many helpful features that we don’t get in the shell script. For example:
When one test fails, the others are still run.
Tests have names, and we see the names of the failed tests..
We can use pytest --lf to run only the last failed tests.
The logging output is cleaner when the tests succeed (just one dot for each passing test).
Moving shell tests into pytest makes things more consistent.
We can use pytest’s tmp_path fixture: Output is created in a temporary location and automatically deleted when the test passes. It is kept if the test fails, and can the be inspected.
We force ourselves to use our own "API" (here, the run_trex function), which is good because we see directly whether using it has problems (I already changed something).
The code is a bit longer, but it’s worth it to me.
This is a first step towards fully eliminating the
test.sh
shell script. pytest is a nice testing framework with many helpful features that we don’t get in the shell script. For example:pytest --lf
to run only the last failed tests.tmp_path
fixture: Output is created in a temporary location and automatically deleted when the test passes. It is kept if the test fails, and can the be inspected.run_trex
function), which is good because we see directly whether using it has problems (I already changed something).The code is a bit longer, but it’s worth it to me.