August 2018
Beginner
160 pages
4h 8m
English
Sometimes, all you need is to construct a simple object for your tests, and arguably this can be done in a plain function, not necessarily needing to be implemented as a fixture. Suppose we have a WindowManager class, that does not receive any parameters:
class WindowManager: ...
One way to use it in our tests would be to write a fixture:
@pytest.fixturedef manager(): return WindowManager()def test_windows_creation(manager): window = manager.new_help_window("pipes_help.rst") assert window.title() == "Pipe Setup Help"
Alternatively, you could argue that a fixture for such simple usage is overkill, and use a plain function instead:
def create_window_manager(): return WindowManager()def test_windows_creation(): ...
Read now
Unlock full access