Skip to content

Commit

Permalink
Implement workaround for pytest issue [#3542](pytest-dev/pytest#3542)
Browse files Browse the repository at this point in the history
There seems to be a bug in pytest where metafunc.parametrize breaks
fixture scope. By creating a fixture and parameterizing it indirectly
scope can be maintained
  • Loading branch information
Barnabas committed Jul 20, 2018
1 parent 8ab12d4 commit f663f0b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion testinfra/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def TestinfraBackend(host):
return host.backend


@pytest.fixture(scope="module")
def _testinfra_host(request):
return request.param


@pytest.fixture(scope="module")
def host(_testinfra_host):
return _testinfra_host
Expand Down Expand Up @@ -148,7 +153,7 @@ def pytest_generate_tests(metafunc):
)
ids = sorted([e.backend.get_pytest_id() for e in params])
metafunc.parametrize(
"_testinfra_host", params, ids=ids, scope="module")
"_testinfra_host", params, ids=ids, scope="module", indirect=True)


def pytest_collection_finish(session):
Expand Down

0 comments on commit f663f0b

Please sign in to comment.