Skip to content

Commit 448563c

Browse files
authored
Merge pull request #11253 from bluetech/11243-cherry-picks
11243 cherry picks
2 parents 430ad14 + e8aa906 commit 448563c

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ Ross Lawley
327327
Ruaridh Williamson
328328
Russel Winder
329329
Ryan Wooden
330+
Sadra Barikbin
330331
Saiprasad Kale
331332
Samuel Colvin
332333
Samuel Dion-Girardeau

src/_pytest/config/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ def _get_legacy_hook_marks(
353353
if TYPE_CHECKING:
354354
# abuse typeguard from importlib to avoid massive method type union thats lacking a alias
355355
assert inspect.isroutine(method)
356-
known_marks: set[str] = {m.name for m in getattr(method, "pytestmark", [])}
357-
must_warn: list[str] = []
358-
opts: dict[str, bool] = {}
356+
known_marks: Set[str] = {m.name for m in getattr(method, "pytestmark", [])}
357+
must_warn: List[str] = []
358+
opts: Dict[str, bool] = {}
359359
for opt_name in opt_names:
360360
opt_attr = getattr(method, opt_name, AttributeError)
361361
if opt_attr is not AttributeError:

src/_pytest/fixtures.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,26 @@ def pytest_addoption(parser: Parser) -> None:
14041404
)
14051405

14061406

1407+
def _get_direct_parametrize_args(node: nodes.Node) -> List[str]:
1408+
"""Return all direct parametrization arguments of a node, so we don't
1409+
mistake them for fixtures.
1410+
1411+
Check https://github.com/pytest-dev/pytest/issues/5036.
1412+
1413+
These things are done later as well when dealing with parametrization
1414+
so this could be improved.
1415+
"""
1416+
parametrize_argnames: List[str] = []
1417+
for marker in node.iter_markers(name="parametrize"):
1418+
if not marker.kwargs.get("indirect", False):
1419+
p_argnames, _ = ParameterSet._parse_parametrize_args(
1420+
*marker.args, **marker.kwargs
1421+
)
1422+
parametrize_argnames.extend(p_argnames)
1423+
1424+
return parametrize_argnames
1425+
1426+
14071427
class FixtureManager:
14081428
"""pytest fixture definitions and information is stored and managed
14091429
from this class.
@@ -1453,25 +1473,6 @@ def __init__(self, session: "Session") -> None:
14531473
}
14541474
session.config.pluginmanager.register(self, "funcmanage")
14551475

1456-
def _get_direct_parametrize_args(self, node: nodes.Node) -> List[str]:
1457-
"""Return all direct parametrization arguments of a node, so we don't
1458-
mistake them for fixtures.
1459-
1460-
Check https://github.com/pytest-dev/pytest/issues/5036.
1461-
1462-
These things are done later as well when dealing with parametrization
1463-
so this could be improved.
1464-
"""
1465-
parametrize_argnames: List[str] = []
1466-
for marker in node.iter_markers(name="parametrize"):
1467-
if not marker.kwargs.get("indirect", False):
1468-
p_argnames, _ = ParameterSet._parse_parametrize_args(
1469-
*marker.args, **marker.kwargs
1470-
)
1471-
parametrize_argnames.extend(p_argnames)
1472-
1473-
return parametrize_argnames
1474-
14751476
def getfixtureinfo(
14761477
self,
14771478
node: nodes.Item,
@@ -1503,7 +1504,7 @@ def getfixtureinfo(
15031504
)
15041505
initialnames = usefixtures + argnames
15051506
initialnames, names_closure, arg2fixturedefs = self.getfixtureclosure(
1506-
initialnames, node, ignore_args=self._get_direct_parametrize_args(node)
1507+
initialnames, node, ignore_args=_get_direct_parametrize_args(node)
15071508
)
15081509
return FuncFixtureInfo(argnames, initialnames, names_closure, arg2fixturedefs)
15091510

0 commit comments

Comments
 (0)