June 2019
Beginner to intermediate
770 pages
19h 24m
English
The fixture functions can also provide a teardown capability as well as a setup capability. This relies on the lazy way generator functions work. Some example code for a fixture that does setup and teardown is as follows:
@fixturedef damaged_file_path(): file_path = Path.cwd() / "data" / "ch17_sample.csv" with file_path.open("w", newline="") as target: print("not_player,bet,rounds,final", file=target) print("data,1,1,1", file=target) yield file_path file_path.unlink()
The damaged_file_path() function creates a file with a relative path of data/ch17_sample.csv. A few lines of data are written to the file.
The yield statement provides an initial result value. This is used by a test function. When the test ...
Read now
Unlock full access