File tree Expand file tree Collapse file tree 2 files changed +52
-3
lines changed Expand file tree Collapse file tree 2 files changed +52
-3
lines changed Original file line number Diff line number Diff line change @@ -138,3 +138,46 @@ async def test():
138
138
f"*ValueError: { run_name !r} not valid for 'trio_run' config. Must be one of: *"
139
139
]
140
140
)
141
+
142
+
143
+ def test_closest_explicit_run_wins (testdir ):
144
+ testdir .makefile (
145
+ ".ini" , pytest = f"[pytest]\n trio_mode = true\n trio_run = trio\n "
146
+ )
147
+ testdir .makepyfile (qtrio = qtrio_text )
148
+
149
+ test_text = """
150
+ import pytest
151
+ import pytest_trio
152
+ import qtrio
153
+
154
+ @pytest.mark.trio(run='should be ignored')
155
+ @pytest.mark.trio(run=qtrio.run)
156
+ async def test():
157
+ assert qtrio.fake_used
158
+ """
159
+ testdir .makepyfile (test_text )
160
+
161
+ result = testdir .runpytest ()
162
+ result .assert_outcomes (passed = 1 )
163
+
164
+
165
+ def test_ini_run_wins_with_blank_marker (testdir ):
166
+ testdir .makefile (
167
+ ".ini" , pytest = f"[pytest]\n trio_mode = true\n trio_run = qtrio\n "
168
+ )
169
+ testdir .makepyfile (qtrio = qtrio_text )
170
+
171
+ test_text = """
172
+ import pytest
173
+ import pytest_trio
174
+ import qtrio
175
+
176
+ @pytest.mark.trio
177
+ async def test():
178
+ assert qtrio.fake_used
179
+ """
180
+ testdir .makepyfile (test_text )
181
+
182
+ result = testdir .runpytest ()
183
+ result .assert_outcomes (passed = 1 )
Original file line number Diff line number Diff line change @@ -353,9 +353,15 @@ def _trio_test_runner_factory(item, testfunc=None):
353
353
else :
354
354
testfunc = item .obj
355
355
356
- config_run = choose_run (config = item .config )
357
- marker = item .get_closest_marker ("trio" )
358
- run = marker .kwargs .get ('run' , config_run )
356
+ for marker in item .iter_markers ("trio" ):
357
+ maybe_run = marker .kwargs .get ('run' )
358
+ if maybe_run is not None :
359
+ run = maybe_run
360
+ break
361
+ else :
362
+ # no marker found that explicitly specifiers the runner so use config
363
+ run = choose_run (config = item .config )
364
+
359
365
360
366
if getattr (testfunc , '_trio_test_runner_wrapped' , False ):
361
367
# We have already wrapped this, perhaps because we combined Hypothesis
You can’t perform that action at this time.
0 commit comments