From ec7a47ee9178ac1bc0e590e12b300c03db08eb2c Mon Sep 17 00:00:00 2001 From: Andres Date: Mon, 18 Mar 2024 16:47:20 -0300 Subject: [PATCH] update tests --- testing/python/fixtures.py | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 1e22270e5..1fb5db2d8 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -1785,6 +1785,54 @@ class TestFixtureManagerParseFactories: result = pytester.runpytest("foo") result.stdout.fnmatch_lines(["*passed*"]) + def test_get_fixture_clousure_override_conftest_module_and_class( + self, pytester: Pytester + ): + pytester.makepyfile( + """\ + import pytest + + @pytest.fixture + def hello(param, hello): + return "module" + class TestClass(object): + @pytest.fixture + def hello(self, hello): + return "class" + + @pytest.mark.parametrize("param", ["foo"]) + def test_hello(self, item, hello, fm): + print(item) + clousurelist, _ = fm.getfixtureclosure(item, ("hello",), {}) + assert clousurelist[0] == ["hello", "param", "request"] + """ + ) + reprec = pytester.inline_run("-s") + reprec.assertoutcome(passed=1) + + def test_get_fixture_clousure_override_module_and_class(self, pytester: Pytester): + pytester.makepyfile( + """\ + import pytest + + @pytest.fixture + def hello(param): + return "module" + class TestClass(object): + @pytest.fixture + def hello(self, hello): + return "class" + @pytest.mark.parametrize("param", ["foo"]) + def test_hello(self, item, hello, fm): + print(item) + clousurelist, _ = fm.getfixtureclosure(item, ("hello",), {}) + print(clousurelist) + assert clousurelist == ["hello", "param"] + """ + ) + reprec = pytester.inline_run("-s") + reprec.assertoutcome(passed=1) + class TestAutouseDiscovery: @pytest.fixture