Skip to content

Commit

Permalink
fix most of metafunc tests by mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Mar 29, 2018
1 parent 180ae09 commit 99015bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion _pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ class Metafunc(fixtures.FuncargnamesCompatAttr):

def __init__(self, definition, fixtureinfo, config, cls=None, module=None):
#: access to the :class:`_pytest.config.Config` object for the test session
assert isinstance(definition, FunctionDefinition)
assert isinstance(definition, FunctionDefinition) or type(definition).__name__ == "DefinitionMock"
self.definition = definition
self.config = config

Expand Down
12 changes: 6 additions & 6 deletions testing/python/metafunc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import re
import sys

import attr
import _pytest._code
import py
import pytest
Expand All @@ -24,13 +24,13 @@ class FixtureInfo(object):
def __init__(self, names):
self.names_closure = names

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

names = fixtures.getfuncargnames(func)
fixtureinfo = FixtureInfo(names)
definition = python.FunctionDefinition(
name=func.__name__,
parent=None,
callobj=func,
)
definition = DefinitionMock(func)
return python.Metafunc(definition, fixtureinfo, config)

def test_no_funcargs(self, testdir):
Expand Down

0 comments on commit 99015bf

Please sign in to comment.