Pytest for Data Science Beginners. No prior testing knowledge is assumed!
This is a tutorial given at PyData Los Angeles 2018
Introduce testing philosophy and code. By end of tutorial attendees will be able to write pytest unit tests themselves. Specifically they will know about
- Pytest test patterns
- Pytest Fixures
- Mock
- Monkeypatch
- References to advanced topics such as parameterized tests and test runner configuration
About the speaker and format of talk
Spoiler alert, yes. Testing is widely used in serious data science. We'll cover examples and real world cases.
This tutorial will have plenty of hands on activities. Each section below will have an instructor explanation followed with a student challenge.
We'll cover how to structure tests for use with pytest, and also an example of why pytest is the preferred testing framework for many projects
Fixtures are an important component of testing that allows for reuse of mutable data structures. If this doesn't make sense now it will after going through this example.
Loading data or running a model sometimes takes minutes or even hours. We'll see how mock can be used to "fake" python data structures to make writing and running tests faster and more isolated.
In data science you'll frequently be using other peoples libraries. This example will show how to alter functionality during testing time and why this is sometimes desired.
We'll have an open discussion about functionality such as parametrization, test finalizers, exception testing, and code coverage
Feedback on this talk is welcome! https://speakerrate.com/events/18193-pydata-los-angeles-2018