diff --git a/tests/conftest.py b/tests/conftest.py index 881d3dbc56..05590af676 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1583,6 +1583,9 @@ def pfc_pause_delay_test_params(request): _frontend_hosts_per_hwsku_per_module = {} _hosts_per_hwsku_per_module = {} + + +@pytest.hookimpl(wrapper=True) def pytest_generate_tests(metafunc): # noqa E302 # The topology always has atleast 1 dut dut_fixture_name = None @@ -1786,6 +1789,26 @@ def format_portautoneg_test_id(param): else: metafunc.parametrize('vlan_name', ['no_vlan'], scope='module') + # HACK: ensure fixture core_dump_and_config_check runs before any + # other module level fixtures in setup to collect configurations + # without modification from test fixtures. + for fixturedef in metafunc._arg2fixturedefs.values(): + fixturedef = fixturedef[0] + if fixturedef.argname == "core_dump_and_config_check": + metafunc.fixturenames.remove(fixturedef.argname) + metafunc.fixturenames.insert(0, fixturedef.argname) + + yield + + # HACK: ensure fixture core_dump_and_config_check runs after any + # other module level fixtures in teardown, so other fixtures could + # restore the configruation before running core_dump_and_config_check. + for fixturedef in metafunc._arg2fixturedefs.values(): + fixturedef = fixturedef[0] + if fixturedef.argname == "core_dump_and_config_check": + metafunc.fixturenames.remove(fixturedef.argname) + metafunc.fixturenames.append(fixturedef.argname) + def get_autoneg_tests_data(): folder = 'metadata'