ESCOMP / CAM-SIMA

Community Atmosphere Model - System for Integrated Modeling of the Atmosphere
3 stars 12 forks source link

Allow pytest to automatically run all python unit tests #192

Closed nusbaume closed 1 year ago

nusbaume commented 1 year ago

This PR is a continuation of the past couple of PRs (#185 and #187) which are designed to simplify and improve the automated python unit testing in CAMDEN.

The biggest change with this PR is that now any python file added to the test/unit directory that is either named test_*.py or *_test.py will automatically be run by Github Actions without the need to modify the workflow code itself. This documentation will be included on a new CAMDEN wiki page once one the cam_builde_cache.py tests are modified to allow for the automatic running of doctests as well.

Along with this change, several doctests were converted to "unittest" tests, to help lay the groundwork for automatic doctest searching by pytest/Github, as well as create a more obvious separation between what should be a doctest and what should be a unittest.

Finally, some minor code mods as recommended by pylint were added as well.

Addresses #190 Addresses #179

nusbaume commented 1 year ago

@gold2718 Just FYI after looking through the official documentation that having multiple >>> lines in a row (or using ...) is allowed, and a variable will be saved in memory for use by other doctests within the docstring block. They even show an example of this in the doctest documentation itself:

https://docs.python.org/3/library/doctest.html#how-are-docstring-examples-recognized

Hopefully that helps with any future doctest development!

gold2718 commented 1 year ago

Hopefully that helps with any future doctest development!

I think it will be a big help, thanks for finding this!

nusbaume commented 1 year ago

Just letting folks know that @cacraigucar was OK with not reviewing this PR.