August 2018
Beginner
160 pages
4h 8m
English
Suppose we receive a new series.csv file that now contains a much larger number of TV series, including the comedy series we had before and many other genres as well. We want to use this new data for some other tests, but we would like to keep existing tests working as they did previously.
Fixtures in pytest can easily depend on other fixtures just by declaring them as parameters. Using this property, we are able to create a new series fixture that reads all the data from series.csv (which now contains more genres), and change our comedy_series fixture to filter out only comedy series:
@pytest.fixturedef series(): with open("series.csv", "r", newline="") as file: return list(csv.reader(file))@pytest.fixturedef comedy_series(series): ...Read now
Unlock full access