|
10 | 10 | import env |
11 | 11 | from pybind11_tests import gil_scoped as m |
12 | 12 |
|
| 13 | +skipif_not_free_threaded = pytest.mark.skipif( |
| 14 | + not getattr(sys, "_is_gil_enabled", lambda: True)(), |
| 15 | + reason="Flaky without the GIL", |
| 16 | +) |
| 17 | + |
13 | 18 |
|
14 | 19 | class ExtendedVirtClass(m.VirtClass): |
15 | 20 | def virtual_func(self): |
@@ -155,7 +160,7 @@ def _intentional_deadlock(): |
155 | 160 | m.intentional_deadlock() |
156 | 161 |
|
157 | 162 |
|
158 | | -ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK = ALL_BASIC_TESTS + (_intentional_deadlock,) |
| 163 | +ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK = (*ALL_BASIC_TESTS, _intentional_deadlock) |
159 | 164 |
|
160 | 165 |
|
161 | 166 | def _run_in_process(target, *args, **kwargs): |
@@ -227,6 +232,7 @@ def test_run_in_process_one_thread(test_fn): |
227 | 232 | assert _run_in_process(_run_in_threads, test_fn, num_threads=1, parallel=False) == 0 |
228 | 233 |
|
229 | 234 |
|
| 235 | +@skipif_not_free_threaded |
230 | 236 | @pytest.mark.skipif(sys.platform.startswith("emscripten"), reason="Requires threads") |
231 | 237 | @pytest.mark.parametrize("test_fn", ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK) |
232 | 238 | @pytest.mark.skipif( |
@@ -256,7 +262,13 @@ def test_run_in_process_multiple_threads_sequential(test_fn): |
256 | 262 |
|
257 | 263 |
|
258 | 264 | @pytest.mark.skipif(sys.platform.startswith("emscripten"), reason="Requires threads") |
259 | | -@pytest.mark.parametrize("test_fn", ALL_BASIC_TESTS_PLUS_INTENTIONAL_DEADLOCK) |
| 265 | +@pytest.mark.parametrize( |
| 266 | + "test_fn", |
| 267 | + [ |
| 268 | + *ALL_BASIC_TESTS, |
| 269 | + pytest.param(_intentional_deadlock, marks=skipif_not_free_threaded), |
| 270 | + ], |
| 271 | +) |
260 | 272 | @pytest.mark.skipif( |
261 | 273 | "env.GRAALPY", |
262 | 274 | reason="GraalPy transiently complains about unfinished threads at process exit", |
|
0 commit comments