Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from collections.abc import Sequence
from functools import partial
from textwrap import dedent
from typing import List
from typing import Tuple

import py
Expand Down Expand Up @@ -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
Expand All @@ -916,7 +920,7 @@ def __init__(self, definition, fixtureinfo, config, cls=None, module=None):
#: 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
Expand Down
4 changes: 2 additions & 2 deletions testing/python/metafunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


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
Expand All @@ -23,7 +23,7 @@ def __init__(self, names):
self.names_closure = names

@attr.s
class DefinitionMock:
class DefinitionMock(python.FunctionDefinition):
obj = attr.ib()

names = fixtures.getfuncargnames(func)
Expand Down