Testing the export function

In the same test module, I have defined another class that represents a test suite for the export function. Here it is:

# tests/test_api.pyclass TestExport:    @pytest.fixture    def csv_file(self, tmpdir):        yield tmpdir.join("out.csv")    @pytest.fixture    def existing_file(self, tmpdir):        existing = tmpdir.join('existing.csv')        existing.write('Please leave me alone...')        yield existing

Let's start understanding the fixtures. We have defined them at class-level this time, which means they will be alive only for as long as the tests in the class are running. We don't need these fixtures outside of this class, so it doesn't make sense to declare them at a module level like we've done with the user ones.

So, we need two files. ...

Get Learn Web Development with Python 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.