Skip to content

Commit d56b1af

Browse files
committed
fixtures: remove no longer needed special case in pytest_generate_tests
Originally added in c00fe96, but since made redundant. The `ignore_args` parameter in `getfixtureclosure()` (populated by `_get_direct_parametrize_args()`) now handles the precedence automatically. When a test directly parametrizes an argument, it's included in `ignore_args`, which prevents the fixture from being included in the closure computation in the first place.
1 parent 9652bc7 commit d56b1af

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

src/_pytest/fixtures.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
from _pytest.deprecated import MARKED_FIXTURE
5757
from _pytest.deprecated import YIELD_FIXTURE
5858
from _pytest.main import Session
59-
from _pytest.mark import Mark
6059
from _pytest.mark import ParameterSet
6160
from _pytest.mark.structures import MarkDecorator
6261
from _pytest.outcomes import fail
@@ -1695,11 +1694,6 @@ def sort_by_scope(arg_name: str) -> Scope:
16951694

16961695
def pytest_generate_tests(self, metafunc: Metafunc) -> None:
16971696
"""Generate new tests based on parametrized fixtures used by the given metafunc"""
1698-
1699-
def get_parametrize_mark_argnames(mark: Mark) -> Sequence[str]:
1700-
args, _ = ParameterSet._parse_parametrize_args(*mark.args, **mark.kwargs)
1701-
return args
1702-
17031697
for argname in metafunc.fixturenames:
17041698
# Get the FixtureDefs for the argname.
17051699
fixture_defs = metafunc._arg2fixturedefs.get(argname)
@@ -1708,14 +1702,6 @@ def get_parametrize_mark_argnames(mark: Mark) -> Sequence[str]:
17081702
# else (e.g @pytest.mark.parametrize)
17091703
continue
17101704

1711-
# If the test itself parametrizes using this argname, give it
1712-
# precedence.
1713-
if any(
1714-
argname in get_parametrize_mark_argnames(mark)
1715-
for mark in metafunc.definition.iter_markers("parametrize")
1716-
):
1717-
continue
1718-
17191705
# In the common case we only look at the fixture def with the
17201706
# closest scope (last in the list). But if the fixture overrides
17211707
# another fixture, while requesting the super fixture, keep going

0 commit comments

Comments
 (0)