This is an intensive 2h30 minute workshop on correctness and testing for scientific software, using Python as the demonstration language with the pytest
framework. It assumes that the attendees have some programming skills, but are not necessarily Python experts. There is some emphasis on scientific computing, with the example being a simple 0D Energy Balance Model (EBM). It would therefore be beneficial if you have some experience in this field, though not strictly necessary.
The slides are included in this repository.
This material was first delivered at the 2025 ICCS summer school.
- 10 minute intro about correctness and testing
- 50 minutes explaining concepts about unit testing including
- Parameterised tests
- Fixtures
- Negative tests
- Approximation and floating point
- TDD
- Code coverage
- 20 minute unit test exercises
- 40 minutes lecture
- Integration and end-to-end tests
- Property-based testing
- 30 minutes exercises (property-based test exercises)
The example
folder provides a small 0-dimensional Energy Balance Model for a planet (with its main configuration being for Earth). See example/README.md
for instructions on its usage. It contains a test suite in the example/tests
directory which is used for demonstration and is the source material for the exercises in exercises.md
, which also provides setup instructions.