`pytest --rm success ...` not working as intended
**Summary** `gmxapi.testsupport` adds support for a `--rm` option to pytest. The value of `success` is supposed to remove the testing temporary directory only when a test succeeds. At some point the logic seems to have broken, and the temporary directory is always removed unless `--rm never`. **GROMACS version** 2020 and newer, but possibly dependent on `pytest` version. **Steps to reproduce** 1. Install gmxapi, or build GROMACS with `-DGMX_PYTHON_PACKAGE=ON` and change to the `${CMAKE_BUILD_DIR}/python_packaging/src/gmxapi_staging` directory. 2. `python -m pytest <other pytest args> --rm success /path/to/python_packaging/src/test/<failing_test>` **What is the current bug behavior?** pytest `--rm never` works as expected, but `--rm success` proceeds as if `--rm always` **What did you expect the correct behavior to be?** As with `--rm never`, the temporary directory for a failed test should not be removed. Unless suppressed, a warning like the following would be visible: ``` ===================================================================================== warnings summary ====================================================================================== test_subgraph.py::test_subgraph_simulation_extension .../python_packaging/src/gmxapi_staging/gmxapi/testsupport.py:194: UserWarning: Temporary directory not removed: /<tmp_dir_path_prefix>/tmp6e9mml_d ``` **Possible fixes** pytest provides `tmp_path` and `tmp_path_factory` fixtures that do most of what we need, but which have a different retention policy that avoids some of the other issues we've run into. We can build on these fixtures, instead. Issues avoided: * race conditions in directory removal * custom policies on temporary directory retention * extra custom command line argument processing * appropriate reporting of the temporary directory path and status
issue