Setup/teardown
As we've seen in the introduction, it is very common for resources that are used in testing to require some sort of clean up after a test is done with them.
In our previous example, we had a very small dataset, so inlining it in the fixture was fine. Suppose however that we have a much larger dataset (say, 1,000 entries), so writing it in the code would hurt readability. Often, the dataset is in an external file, for example, in CSV format, so porting it into the Python code is a pain.
A solution to that would be to commit the CSV file containing the series dataset into the repository and read it inside the test, using the built-in csv module; for more details go to https://docs.python.org/3/library/csv.html.
We can change ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access