August 2018
Beginner
160 pages
4h 8m
English
You can apply the @pytest.mark decorator to a class. This will apply that same mark to all tests methods in that class, avoiding have to copy and paste the mark code over all test methods:
@pytest.mark.timeout(10)class TestCore: def test_simple_simulation(self): ... def test_compute_tracers(self): ...
The previous code is essentially the same as the following code:
class TestCore: @pytest.mark.timeout(10) def test_simple_simulation(self): ... @pytest.mark.timeout(10) def test_compute_tracers(self): ...
However, there is one difference: applying the @pytest.mark decorator to a class means that all its subclasses will inherit the mark. Subclassing test classes is not common, but it is sometimes a useful technique to ...
Read now
Unlock full access