PyCon 2016 in Portland, Or
hills next to breadcrumb illustration

Sunday 9 a.m.–12:20 p.m.

Introduction to Unit Testing in Python with Pytest

Michael Tom-Wing, Christie Wilson

Audience level:


In this tutorial we’ll be taking you on a journey into the wonderful land of unit testing with pytest. We’ll be taking a step by step approach by iteratively adding unit test coverage to our awesome Cat In A Box™ project. You will also get a crash course on Git, Github, virtualenvs, and test automation. By the end, we hope that you’ll have a desire to bring testing to our own projects!


## Learning Objectives - What tests are and why they are important - What unit tests are and why you should write them - How to approach writing unit tests - Why you need test automation - Some ways to measure code / test quality - Why pytest is awesome and how it helps you test better - Mocking, fixtures, and parametrization - oh my! - Hopefully none of our bad habits :) ## Prerequisites Students should have at least a novice to beginner level understanding of Python. No prior experience with testing (in general or with Python) is required as we'll be starting from basics. We also ask that students have the following on their laptop: - Python 2.7 or 3.4+ - Git - Pip and Virtualenv [1] It would also be beneficial with students can create a Github account (and attach their SSH key) beforehand, and to fork and clone [our repo]( [1] Windows users should also considering installing the Community Edition of [PyCharm]( as it simplifies getting both Pip and Virtualenv.

Student Handout

No handouts have been provided yet for this tutorial