Testing Python code with pytest
Date and Time
September 19, 2022
01:00PM - 02:30PM EDT
Location
Virtual, Zoom
Presented by Nick Murphy
Software tests give us confidence that our code is working correctly. Tests help us find and fix bugs, preferably as soon as we introduce them. When working with code that is well-tested, we are able to change the code with confidence that we are not introducing hidden bugs elsewhere in the program. Software tests reduce frustration and make our lives easier. Even though tests are considered vital in software engineering, testing has been applied irregularly to scientific software. This tutorial will introduce how to write and run Python tests using pytest. We will cover assertions, exceptions, how to write unit tests, how to run tests with pytest, test parameterization, and test-driven development. We will end with a discussion on software testing best practices, how to decide on what tests to write, and how to write code that is easy to test.