October 2018
Beginner to intermediate
466 pages
12h 2m
English
pytest supports setup and teardown methods similar to those used in unittest, but it provides even more flexibility. We'll discuss these briefly, since they are familiar, but they are not used as extensively as in the unittest module, as pytest provides us with a powerful fixtures facility, which we'll discuss in the next section.
If we are writing class-based tests, we can use two methods called setup_method and teardown_method in the same way that setUp and tearDown are called in unittest. They are called before and after each test method in the class to perform setup and cleanup duties. There is one difference from the unittest methods though. Both methods accept an argument: the function object representing ...