Skip to content

Commit

Permalink
tests: handle DefinitionMock
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Jan 31, 2020
1 parent 149bddb commit de91222
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/_pytest/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,12 @@ def __call__(cls, *args, **kwargs):
sig = inspect.signature(cls.__init__)
bsig = sig.bind(cls, *args, **kwargs)
if "parent" not in bsig.arguments:
warnings.warn(
NODE_USE_FROM_PARENT.format(name=cls.__name__), stacklevel=2
)
# XXX: handle DefinitionMock from tests. Could also go through
# _create instead (or get fixed?)?
if not getattr(cls, "_pytest_skip_ctor_check", False):
warnings.warn(
NODE_USE_FROM_PARENT.format(name=cls.__name__), stacklevel=2
)
return super().__call__(*args, **kwargs)


Expand Down
1 change: 1 addition & 0 deletions testing/python/metafunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, names):

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

names = fixtures.getfuncargnames(func)
Expand Down

0 comments on commit de91222

Please sign in to comment.