In this episode, I replaced the default Django test runner to use pytest. We walked through installation, configuration, how to change tests, and the benefits that come from using pytest.
We started by looking at the current state
of the test suite
to provide a baseline
to compare against.
I went to PyPI
to find the version of
that we wanted to install.
I added the package to my
and installed the update.
$ pip install -r requirements-dev.txt
I created a
and configured the package
by setting the
I initially typed the name of the setting incorrectly
(forgetting the second
so we debugged the failure case too.
Once pytest was running, we observed that all the tests passed. This behavior surprised me because I thought that the test would need to be marked to use a database. We dug into the details of the test execution to see which Python fixtures were used. We talked a bit about how fixtures worked.
I finished the stream
by going through some tests
and switching the assertion styles.
We compared and contrasted assertions
unittest style tests
versus pytest assertions.