iris icon indicating copy to clipboard operation
iris copied to clipboard

Remove test file runnability

Open trexfeathers opened this issue 1 year ago • 3 comments

Historically our test files have been runnable as independent Python scripts e.g. python test_pp_cf.py. We even customise the help message e.g. python test_pp_cf.py --help.

This relies on the block below, plus the inclusion of if __name__ == "__main__": tests.main() in every test file.

https://github.com/SciTools/iris/blob/c6151e819189ca213b370ddf4ff38d8511c7e012/lib/iris/tests/init.py#L91-L135

Now we are using PyTest I often do not import the tests module, and I have not bothered making my files runnable since they are intended to be run via PyTest e.g. pytest test_pp_cf.py.

I think we should remove the runnability from our tests, and if those extra command line options are important then we should explore how they can be offered via PyTest configurability instead. Happy to discuss.

trexfeathers avatar Mar 11 '24 12:03 trexfeathers

This would be consistent with the decision in cf-units to remove the ifmains: https://github.com/SciTools/cf-units/pull/245

rcomer avatar Mar 11 '24 12:03 rcomer

It makes sense to me.

pp-mo avatar Mar 11 '24 14:03 pp-mo