Skip to content

Commit

Permalink
put slow tests first
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Sep 20, 2024
1 parent 6bcca8a commit 260a8b9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions jwst/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@
from jwst.associations.tests.helpers import t_path


# slow test modules (and an example runtime for their slowest test)
# the runtime is likely dominated by a fixutre reused for tests in that module
_SLOW_TEST_MODULES = [
'jwst.regtest.test_nirspec_ifu_spec3_pixelreplace', # 4213 seconds
'jwst.regtest.test_nirspec_ifu_spec3', # 3698 seconds
'jwst.regtest.test_nirspec_ifu_spec3_emsm', # 3129 seconds
'jwst.regtest.test_niriss_soss', # 2739 seconds
'jwst.regtest.test_nirspec_ifu_spec2', # 1382 seconds
'jwst.regtest.test_nrispec_lamp_ifu_spec2', # 847 seconds
'jwst.regtest.test_nirspec_steps_spec2', # 710 seconds
]


def _get_test_item_module_name(item):
if not hasattr(item, 'module'):
return None
return item.module.__name__


@pytest.hookimpl(trylast=True)
def pytest_collection_modifyitems(config, items):
# reorder tests to put known slow ones first, this helps
# to prevent slow tests from starting later in the test run
for (i, module_name) in enumerate(_SLOW_TEST_MODULES):
if _get_test_item_module_name(items[i]) != module_name:
# swap this with a later test not in a slow module
for j in range(i, len(items)):
if _get_test_item_module_name(items[j]) == module_name:
items[i], items[j] = items[j], items[i]
break
return items


@pytest.fixture
def jail_environ():
"""Lock changes to the environment"""
Expand Down

0 comments on commit 260a8b9

Please sign in to comment.