|
37 | 37 | sp_version,
|
38 | 38 | )
|
39 | 39 |
|
| 40 | +try: |
| 41 | + import pytest_run_parallel # noqa:F401 |
| 42 | + |
| 43 | + PARALLEL_RUN_AVAILABLE = True |
| 44 | +except ImportError: |
| 45 | + PARALLEL_RUN_AVAILABLE = False |
| 46 | + |
| 47 | + |
40 | 48 | try:
|
41 | 49 | from scipy_doctest.conftest import dt_config
|
42 | 50 | except ModuleNotFoundError:
|
@@ -317,6 +325,11 @@ def pytest_generate_tests(metafunc):
|
317 | 325 | metafunc.parametrize("global_random_seed", random_seeds)
|
318 | 326 |
|
319 | 327 |
|
| 328 | +def pytest_addoption(parser, pluginmanager): |
| 329 | + if not PARALLEL_RUN_AVAILABLE: |
| 330 | + parser.addini("thread_unsafe_fixtures", "list of stuff") |
| 331 | + |
| 332 | + |
320 | 333 | def pytest_configure(config):
|
321 | 334 | # Use matplotlib agg backend during the tests including doctests
|
322 | 335 | try:
|
@@ -346,6 +359,25 @@ def pytest_configure(config):
|
346 | 359 | faulthandler.enable()
|
347 | 360 | faulthandler.dump_traceback_later(faulthandler_timeout, exit=True)
|
348 | 361 |
|
| 362 | + if not PARALLEL_RUN_AVAILABLE: |
| 363 | + config.addinivalue_line( |
| 364 | + "markers", |
| 365 | + "parallel_threads(n): run the given test function in parallel " |
| 366 | + "using `n` threads.", |
| 367 | + ) |
| 368 | + config.addinivalue_line( |
| 369 | + "markers", |
| 370 | + "thread_unsafe: mark the test function as single-threaded", |
| 371 | + ) |
| 372 | + config.addinivalue_line( |
| 373 | + "markers", |
| 374 | + "iterations(n): run the given test function `n` times in each thread", |
| 375 | + ) |
| 376 | + config.addinivalue_line( |
| 377 | + "markers", |
| 378 | + "iterations(n): run the given test function `n` times in each thread", |
| 379 | + ) |
| 380 | + |
349 | 381 |
|
350 | 382 | @pytest.fixture
|
351 | 383 | def hide_available_pandas(monkeypatch):
|
|
0 commit comments