diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index bc091bb1f..1f2d44669 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -2199,14 +2199,14 @@ class TestAutouseManagement: ) -> None: """#226""" pytester.makepyfile( - """ + f""" import pytest values = [] - @pytest.fixture(%(param1)s) + @pytest.fixture({param1}) def arg1(request): request.addfinalizer(lambda: values.append("fin1")) values.append("new1") - @pytest.fixture(%(param2)s) + @pytest.fixture({param2}) def arg2(request, arg1): request.addfinalizer(lambda: values.append("fin2")) values.append("new2") @@ -2215,8 +2215,7 @@ class TestAutouseManagement: pass def test_check(): assert values == ["new1", "new2", "fin2", "fin1"] - """ # noqa: UP031 (python syntax issues) - % locals() + """ ) reprec = pytester.inline_run("-s") reprec.assertoutcome(passed=2) @@ -3096,21 +3095,21 @@ class TestFixtureMarker: ) -> None: """#246""" pytester.makepyfile( - """ + f""" import pytest values = [] - @pytest.fixture(scope=%(scope)r, params=["1"]) + @pytest.fixture(scope={scope!r}, params=["1"]) def fix1(request): return request.param - @pytest.fixture(scope=%(scope)r) + @pytest.fixture(scope={scope!r}) def fix2(request, base): def cleanup_fix2(): assert not values, "base should not have been finalized" request.addfinalizer(cleanup_fix2) - @pytest.fixture(scope=%(scope)r) + @pytest.fixture(scope={scope!r}) def base(request, fix1): def cleanup_base(): values.append("fin_base") @@ -3123,8 +3122,7 @@ class TestFixtureMarker: pass def test_other(): pass - """ # noqa: UP031 (python syntax issues) - % {"scope": scope} + """ ) reprec = pytester.inline_run("-lvs") reprec.assertoutcome(passed=3) @@ -3310,42 +3308,40 @@ class TestRequestScopeAccess: def test_setup(self, pytester: Pytester, scope, ok, error) -> None: pytester.makepyfile( - """ + f""" import pytest - @pytest.fixture(scope=%r, autouse=True) + @pytest.fixture(scope={scope!r}, autouse=True) def myscoped(request): - for x in %r: + for x in {ok.split()}: assert hasattr(request, x) - for x in %r: + for x in {error.split()}: pytest.raises(AttributeError, lambda: getattr(request, x)) assert request.session assert request.config def test_func(): pass - """ # noqa: UP031 (python syntax issues) - % (scope, ok.split(), error.split()) + """ ) reprec = pytester.inline_run("-l") reprec.assertoutcome(passed=1) def test_funcarg(self, pytester: Pytester, scope, ok, error) -> None: pytester.makepyfile( - """ + f""" import pytest - @pytest.fixture(scope=%r) + @pytest.fixture(scope={scope!r}) def arg(request): - for x in %r: + for x in {ok.split()!r}: assert hasattr(request, x) - for x in %r: + for x in {error.split()!r}: pytest.raises(AttributeError, lambda: getattr(request, x)) assert request.session assert request.config def test_func(arg): pass - """ # noqa: UP031 (python syntax issues) - % (scope, ok.split(), error.split()) + """ ) reprec = pytester.inline_run() reprec.assertoutcome(passed=1)