Skip to content

Use pytest instead of unittest in run_ctsm_py_tests#3761

Merged
samsrabin merged 8 commits intoESCOMP:b4b-devfrom
samsrabin:run_ctsm_py_tests-in-pytest
Feb 19, 2026
Merged

Use pytest instead of unittest in run_ctsm_py_tests#3761
samsrabin merged 8 commits intoESCOMP:b4b-devfrom
samsrabin:run_ctsm_py_tests-in-pytest

Conversation

@samsrabin
Copy link
Copy Markdown
Member

@samsrabin samsrabin commented Feb 14, 2026

Description of changes

This PR changes run_ctsm_py_tests to use pytest instead of unittest, enabling many modern features. One test file, test_unit_longitude.py, has been modified to use pytest's "parametrize" functionality as an example. Most of the changed lines in that file are just whitespace differences.

Existing run_ctsm_py_tests arguments have been ported to replicate the same functionality in pytest. Unknown arguments will be passed to pytest directly.

Also: Made it so that the tests can be called from anywhere in the checkout, instead of only python/.

Specific notes

Contributors other than yourself, if any: None

CTSM Issues Fixed:

Are answers expected to change (and if so in what way)? No

Any User Interface Changes (namelist or namelist defaults changes)? No

Does this create a need to change or add documentation? Did you do so? No

Testing performed, if any: Python unit and system tests pass. New version finds the same number of tests as before.

@samsrabin samsrabin self-assigned this Feb 14, 2026
@samsrabin samsrabin added next this should get some attention in the next week or two. Normally each Thursday SE meeting. b4b bit-for-bit test: python Pass clm_pymods test suite plus Python sys/unit tests before merging labels Feb 14, 2026
@samsrabin samsrabin force-pushed the run_ctsm_py_tests-in-pytest branch from c656824 to cdebf7a Compare February 17, 2026 17:32
@samsrabin samsrabin force-pushed the run_ctsm_py_tests-in-pytest branch from cdebf7a to f1d6f44 Compare February 18, 2026 16:36
Comment thread python/ctsm/run_ctsm_py_tests.py Outdated
Comment thread python/ctsm/run_ctsm_py_tests.py
@samsrabin samsrabin removed the next this should get some attention in the next week or two. Normally each Thursday SE meeting. label Feb 18, 2026
Copy link
Copy Markdown
Contributor

@slevis-lmwg slevis-lmwg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samsrabin and I did a walkthrough. Thanks for this work, Sam, looks good!

Sam was going to improve comments on a certain method. Sam posted one or two other reminders for himself.

One thing I forgot to mention in our meeting:
You pointed out a print statement at some point, which made me think that elsewhere we try to use logger tools. I'm not pushing for that, just mentioning.

@samsrabin
Copy link
Copy Markdown
Member Author

samsrabin commented Feb 18, 2026

  • Use logging instead of print()

@samsrabin samsrabin merged commit b139f6b into ESCOMP:b4b-dev Feb 19, 2026
6 checks passed
@slevis-lmwg slevis-lmwg mentioned this pull request Feb 20, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

b4b bit-for-bit test: python Pass clm_pymods test suite plus Python sys/unit tests before merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants