Skip to content

Session scoped fixture run multiple times when adding fixture via metafunc #5738 #12931

Closed as not planned
@grtdeveloper

Description

@grtdeveloper

Refering to this ticket : Session scoped fixture run multiple times when adding fixture via metafunc
#5738 : i am trying to achieve the following:

----conftest.py ----
s1_sheet_config, boot_config etc are lists.

def pytest_generate_tests(metafunc):
"""Dynamically parameterize tests based on loaded configurations."""
if 's1_sheet_idx' in metafunc.fixturenames:
metafunc.parametrize("s1_sheet_idx", [s1_sheet_config], indirect=True)

if 'bt_sheet_idx' in metafunc.fixturenames:
    metafunc.parametrize("bt_sheet_idx", [boot_config], indirect=True)

if 'test_idx' in metafunc.fixturenames:
    metafunc.parametrize("test_idx", [test_config], indirect=True)

if 'dt_idx' in metafunc.fixturenames:
    metafunc.parametrize("dt_idx", [dt_config], indirect=True)

---- main.py----

@pytest.mark.parametrize("index", bt_sheet_idx)
def test_boot__sanity(self, index, obj_basic_config=TestBootConfig(), upd_count=TestIncrement(), test_reg=Register()):
......

@pytest.mark.parametrize("index", dt_idx)
def test_dev_sanity(self, index, obj_basic_config=TestBootConfig(), upd_count=TestIncrement(), test_reg=Register()):
.....

I want to execute the complete tests defined in the main.py file for one set of parametrized input first then the reload the new values for the next session and exectue the same tests again for the new set of loaded values.

Test Result should be:
test_boot_sanity [1-1-0] -- PASSED --> Test function for 0 index value
test_boot_sanity [1-1-1] -- PASSED --> Test function for 1 index value
test_boot_sanity [1-2-2] -- PASSED --> Test function for 2 index
:
test_dev_sanity [ 2-2-0] -- PASSED
test_dev_sanity [ 2-2-1] -- PASSED
test_dev_sanity [ 2-2-2] -- PASSED

However, seems only first case is executing... Any help is much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    stalestatus: needs informationreporter needs to provide more information; can be closed after 2 or more weeks of inactivitytopic: fixturesanything involving fixtures directly or indirectly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions