Chapter 6. Improving Functional Tests: Ensuring Isolation and Removing Voodoo Sleeps
Before we dive in and fix our single-global-list problem,
let’s take care of a couple of housekeeping items.
At the end of the last chapter, we made a note
that different test runs were interfering with each other, so we’ll fix that.
I’m also not happy with all these time.sleep
s peppered through the code;
they seem a bit unscientific, so we’ll replace them with something more reliable.
Both of these changes will be moving us towards testing “best practices”, making our tests more deterministic and more reliable.
Ensuring Test Isolation in Functional Tests
We ended the last chapter with a classic testing problem: how to ensure isolation between tests. Each run of our functional tests was leaving list items lying around in the database, and that would interfere with the test results ...
Get Test-Driven Development with Python, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.