def METHOD_NAME(dummy_fixture_store, scope_manager, tests_by_module):
    # pylint: disable=protected-access
    last_scopes = None
    for module_index, tests in enumerate(tests_by_module):
        for test_index, test in enumerate(tests):
            scope_manager.begin_test(test)
            assert dummy_fixture_store._scopes == ['session', 'module', 'test']
            expected = _increment_scope(
                last_scopes,
                test=1,
                module=1 if test_index == 0 else 0,
                session=1 if test_index == 0 and module_index == 0 else 0)
            assert dummy_fixture_store._scope_ids == expected
            # make sure the dict is copied
            assert expected is not dummy_fixture_store._scope_ids
            last_scopes = expected
            scope_manager.end_test(test)
            assert dummy_fixture_store._scopes == ['session', 'module']
            assert dummy_fixture_store._scope_ids == last_scopes
    scope_manager.flush_remaining_scopes()
    assert not dummy_fixture_store._scopes