Skip to content

Commit b4ff6b3

Browse files
authored
Metafunc: remove hack for DefinitionMock (#6223)
2 parents 64d8910 + 2ad2fbc commit b4ff6b3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/_pytest/python.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from collections.abc import Sequence
1010
from functools import partial
1111
from textwrap import dedent
12+
from typing import List
1213
from typing import Tuple
1314

1415
import py
@@ -894,11 +895,14 @@ class Metafunc:
894895
test function is defined.
895896
"""
896897

897-
def __init__(self, definition, fixtureinfo, config, cls=None, module=None):
898-
assert (
899-
isinstance(definition, FunctionDefinition)
900-
or type(definition).__name__ == "DefinitionMock"
901-
)
898+
def __init__(
899+
self,
900+
definition: "FunctionDefinition",
901+
fixtureinfo,
902+
config,
903+
cls=None,
904+
module=None,
905+
) -> None:
902906
self.definition = definition
903907

904908
#: access to the :class:`_pytest.config.Config` object for the test session
@@ -916,7 +920,7 @@ def __init__(self, definition, fixtureinfo, config, cls=None, module=None):
916920
#: class object where the test function is defined in or ``None``.
917921
self.cls = cls
918922

919-
self._calls = []
923+
self._calls = [] # type: List[CallSpec2]
920924
self._arg2fixturedefs = fixtureinfo.name2fixturedefs
921925

922926
@property

testing/python/metafunc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414
class TestMetafunc:
15-
def Metafunc(self, func, config=None):
15+
def Metafunc(self, func, config=None) -> python.Metafunc:
1616
# the unit tests of this class check if things work correctly
1717
# on the funcarg level, so we don't need a full blown
1818
# initialization
@@ -23,7 +23,7 @@ def __init__(self, names):
2323
self.names_closure = names
2424

2525
@attr.s
26-
class DefinitionMock:
26+
class DefinitionMock(python.FunctionDefinition):
2727
obj = attr.ib()
2828

2929
names = fixtures.getfuncargnames(func)

0 commit comments

Comments
 (0)