@pytest.mark.parametrize('autouse_scope', ['session', 'module', pytest.param('function', marks=pytest.mark.xfail)])
def test_session_autouse_and_usefixture_module_scope_runs_before_function_fixtures(testdir, autouse_scope):
    testdir.makepyfile('\n        import pytest\n        from pytest_lazyfixture import lazy_fixture\n\n        invocation_order = []\n\n        @pytest.fixture(autouse=True, scope=\'{autouse_scope}\')\n        def autouse_fixture():\n            invocation_order.append(\'using autouse_fixture\')\n\n        @pytest.fixture(scope=\'module\')\n        def module_fixture():\n            invocation_order.append(\'using module fixture\')\n\n        @pytest.fixture\n        def fixture1():\n            invocation_order.append("using fixture1")\n            return \'fixture1\'\n\n        @pytest.fixture\n        def fixture2():\n            invocation_order.append("using fixture2")\n            return \'fixture2\'\n\n        @pytest.mark.usefixtures("module_fixture")\n        @pytest.mark.parametrize("fixt", [lazy_fixture("fixture1"), lazy_fixture("fixture2")])\n        def test_test(fixt):\n            if fixt == \'fixture2\':\n                print(\' \'.join(invocation_order))\n    '.format(autouse_scope=autouse_scope))
    result = testdir.runpytest('-s')
    assert ('using autouse_fixture using module fixture using fixture1 using fixture2' in result.stdout.str())
@pytest.mark.parametrize('autouse_scope', ['session', 'module', pytest.param('function', marks=pytest.mark.xfail)])
def test_session_autouse_and_usefixture_module_scope_runs_before_function_fixtures(testdir, autouse_scope):
    testdir.makepyfile('\n        import pytest\n        from pytest_lazyfixture import lazy_fixture\n\n        invocation_order = []\n\n        @pytest.fixture(autouse=True, scope=\'{autouse_scope}\')\n        def autouse_fixture():\n            invocation_order.append(\'using autouse_fixture\')\n\n        @pytest.fixture(scope=\'module\')\n        def module_fixture():\n            invocation_order.append(\'using module fixture\')\n\n        @pytest.fixture\n        def fixture1():\n            invocation_order.append("using fixture1")\n            return \'fixture1\'\n\n        @pytest.fixture\n        def fixture2():\n            invocation_order.append("using fixture2")\n            return \'fixture2\'\n\n        @pytest.mark.usefixtures("module_fixture")\n        @pytest.mark.parametrize("fixt", [lazy_fixture("fixture1"), lazy_fixture("fixture2")])\n        def test_test(fixt):\n            if fixt == \'fixture2\':\n                print(\' \'.join(invocation_order))\n    '.format(autouse_scope=autouse_scope))
    result = testdir.runpytest('-s')
    assert ('using autouse_fixture using module fixture using fixture1 using fixture2' in result.stdout.str())