Metafunc: remove hack for DefinitionMock

Done initially in 99015bfc8.
This commit is contained in:
Daniel Hahler 2019-11-18 17:36:15 +01:00
parent 64d8910516
commit 2ad2fbc9a2
2 changed files with 12 additions and 8 deletions

View File

@ -9,6 +9,7 @@ from collections import Counter
from collections.abc import Sequence from collections.abc import Sequence
from functools import partial from functools import partial
from textwrap import dedent from textwrap import dedent
from typing import List
from typing import Tuple from typing import Tuple
import py import py
@ -894,11 +895,14 @@ class Metafunc:
test function is defined. test function is defined.
""" """
def __init__(self, definition, fixtureinfo, config, cls=None, module=None): def __init__(
assert ( self,
isinstance(definition, FunctionDefinition) definition: "FunctionDefinition",
or type(definition).__name__ == "DefinitionMock" fixtureinfo,
) config,
cls=None,
module=None,
) -> None:
self.definition = definition self.definition = definition
#: access to the :class:`_pytest.config.Config` object for the test session #: 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``. #: class object where the test function is defined in or ``None``.
self.cls = cls self.cls = cls
self._calls = [] self._calls = [] # type: List[CallSpec2]
self._arg2fixturedefs = fixtureinfo.name2fixturedefs self._arg2fixturedefs = fixtureinfo.name2fixturedefs
@property @property

View File

@ -12,7 +12,7 @@ from _pytest import python
class TestMetafunc: 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 # the unit tests of this class check if things work correctly
# on the funcarg level, so we don't need a full blown # on the funcarg level, so we don't need a full blown
# initialization # initialization
@ -23,7 +23,7 @@ class TestMetafunc:
self.names_closure = names self.names_closure = names
@attr.s @attr.s
class DefinitionMock: class DefinitionMock(python.FunctionDefinition):
obj = attr.ib() obj = attr.ib()
names = fixtures.getfuncargnames(func) names = fixtures.getfuncargnames(func)