summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/_pytest/python.py16
-rw-r--r--testing/python/metafunc.py4
2 files changed, 12 insertions, 8 deletions
diff --git a/src/_pytest/python.py b/src/_pytest/python.py
index ebc6895f2..2e8756289 100644
--- a/src/_pytest/python.py
+++ b/src/_pytest/python.py
@@ -9,6 +9,7 @@ from collections import Counter
from collections.abc import Sequence
from functools import partial
from textwrap import dedent
+from typing import List
from typing import Tuple
import py
@@ -894,11 +895,14 @@ class Metafunc:
test function is defined.
"""
- def __init__(self, definition, fixtureinfo, config, cls=None, module=None):
- assert (
- isinstance(definition, FunctionDefinition)
- or type(definition).__name__ == "DefinitionMock"
- )
+ def __init__(
+ self,
+ definition: "FunctionDefinition",
+ fixtureinfo,
+ config,
+ cls=None,
+ module=None,
+ ) -> None:
self.definition = definition
#: access to the :class:`_pytest.config.Config` object for the test session
@@ -916,7 +920,7 @@ class Metafunc:
#: class object where the test function is defined in or ``None``.
self.cls = cls
- self._calls = []
+ self._calls = [] # type: List[CallSpec2]
self._arg2fixturedefs = fixtureinfo.name2fixturedefs
@property
diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py
index 0c3c2aed3..1c396c4a7 100644
--- a/testing/python/metafunc.py
+++ b/testing/python/metafunc.py
@@ -12,7 +12,7 @@ from _pytest import python
class TestMetafunc:
- def Metafunc(self, func, config=None):
+ def Metafunc(self, func, config=None) -> python.Metafunc:
# the unit tests of this class check if things work correctly
# on the funcarg level, so we don't need a full blown
# initialization
@@ -23,7 +23,7 @@ class TestMetafunc:
self.names_closure = names
@attr.s
- class DefinitionMock:
+ class DefinitionMock(python.FunctionDefinition):
obj = attr.ib()
names = fixtures.getfuncargnames(func)