September 2017
Intermediate to advanced
222 pages
5h 1m
English
So far, if you wanted a test to use a fixture, you put it in the parameter list. You can also mark a test or a class with @pytest.mark.usefixtures(’fixture1’, ’fixture2’). usefixtures takes a string that is composed of a comma-separated list of fixtures to use. It doesn’t make sense to do this with test functions—it’s just more typing. But it does work well for test classes:
| | @pytest.mark.usefixtures('class_scope') |
| | class TestSomething(): |
| | """Demo class scope fixtures.""" |
| | |
| | def test_3(self): |
| | """Test using a class scope fixture.""" |
| | |
| | def test_4(self): |
| | """Again, multiple tests are more fun.""" |
Using usefixtures is almost the same as specifying the fixture name in the ...
Read now
Unlock full access