remove use of formatting in test_func_closure_module_auto
this makes it apparent that pytester should supply some kind of variable support
This commit is contained in:
parent
982b614010
commit
5582ad0445
|
@ -3790,17 +3790,28 @@ def test_pytest_fixture_setup_and_post_finalizer_hook(testdir):
|
||||||
class TestScopeOrdering(object):
|
class TestScopeOrdering(object):
|
||||||
"""Class of tests that ensure fixtures are ordered based on their scopes (#2405)"""
|
"""Class of tests that ensure fixtures are ordered based on their scopes (#2405)"""
|
||||||
|
|
||||||
@pytest.mark.parametrize("use_mark", [True, False])
|
@pytest.mark.parametrize("variant", ["mark", "autouse"])
|
||||||
def test_func_closure_module_auto(self, testdir, use_mark):
|
@pytest.mark.issue(github="#2405")
|
||||||
|
def test_func_closure_module_auto(self, testdir, variant, monkeypatch):
|
||||||
"""Semantically identical to the example posted in #2405 when ``use_mark=True``"""
|
"""Semantically identical to the example posted in #2405 when ``use_mark=True``"""
|
||||||
|
monkeypatch.setenv("FIXTURE_ACTIVATION_VARIANT", variant)
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
|
import warnings
|
||||||
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
|
VAR = 'FIXTURE_ACTIVATION_VARIANT'
|
||||||
|
VALID_VARS = ('autouse', 'mark')
|
||||||
|
|
||||||
@pytest.fixture(scope='module', autouse={autouse})
|
VARIANT = os.environ.get(VAR)
|
||||||
|
if VARIANT is None or VARIANT not in VALID_VARS:
|
||||||
|
warnings.warn(\"{!r}\" is not in {}, assuming autouse".format(VARIANT, VALID_VARS) )
|
||||||
|
variant = 'mark'
|
||||||
|
|
||||||
|
@pytest.fixture(scope='module', autouse=VARIANT == 'autouse')
|
||||||
def m1(): pass
|
def m1(): pass
|
||||||
|
|
||||||
if {use_mark}:
|
if VARIANT=='mark':
|
||||||
pytestmark = pytest.mark.usefixtures('m1')
|
pytestmark = pytest.mark.usefixtures('m1')
|
||||||
|
|
||||||
@pytest.fixture(scope='function', autouse=True)
|
@pytest.fixture(scope='function', autouse=True)
|
||||||
|
@ -3808,9 +3819,7 @@ class TestScopeOrdering(object):
|
||||||
|
|
||||||
def test_func(m1):
|
def test_func(m1):
|
||||||
pass
|
pass
|
||||||
""".format(
|
"""
|
||||||
autouse=not use_mark, use_mark=use_mark
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
items, _ = testdir.inline_genitems()
|
items, _ = testdir.inline_genitems()
|
||||||
request = FixtureRequest(items[0])
|
request = FixtureRequest(items[0])
|
||||||
|
|
Loading…
Reference in New Issue