Appendix 5xUnit Fixtures
In addition to the fixture model described in Chapter 3, pytest Fixtures, pytest also supports xUnit style fixtures, which are similar to jUnit for Java, cppUnit for C++, and so on.
Generally, xUnit frameworks use a flow of control that looks something like this:
| setup() |
| test_function() |
| teardown() |
This is repeated for every test that will run. pytest fixtures can do anything you need this type of configuration for and more, but if you really want to have setup() and teardown() functions, pytest allows that, too, with some limitations.
Get Python Testing with pytest 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.