Commit f69dca4
committed
pytestplugin/hooks: check for broken strategy state in pytest_runtest_setup()
Now that a strategy can be marked broken, check for that before
executing a test and its fixtures. If a broken strategy is found in one
of the targets, skip the test. It's not worth continuing with it. It
only leads to cascading errors.
The check for brokenness cannot be performed in the strategy fixture
itself because it's session scoped, meaning it only runs for the first
test requesting it (directly or indirectly). So wrap pytest's
pytest_runtest_setup hook running before fixture/test exexcution, Check
if the test requested the strategy fixture (directly or indirectly) and
perform the check only in that case.
Since we cannot know what target the strategy acts on (the target
fixture might be overridden by the test suite), simply check all targets
for broken strategies and skip the test if any of these have a broken
strategy.
This means a strategy exception leads to either a test error (when
triggered in a fixture) or a test fail (when triggered in the test
itself). All subsequent tests requesting the broken strategy (via the
strategy fixture) will be skipped.
Signed-off-by: Bastian Krause <bst@pengutronix.de>1 parent ea2a464 commit f69dca4
2 files changed
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
0 commit comments