fix most of metafunc tests by mocking
This commit is contained in:
parent
180ae09202
commit
99015bfc86
|
@ -736,7 +736,7 @@ class Metafunc(fixtures.FuncargnamesCompatAttr):
|
||||||
|
|
||||||
def __init__(self, definition, fixtureinfo, config, cls=None, module=None):
|
def __init__(self, definition, fixtureinfo, config, cls=None, module=None):
|
||||||
#: access to the :class:`_pytest.config.Config` object for the test session
|
#: 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.definition = definition
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import attr
|
||||||
import _pytest._code
|
import _pytest._code
|
||||||
import py
|
import py
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -24,13 +24,13 @@ class TestMetafunc(object):
|
||||||
def __init__(self, names):
|
def __init__(self, names):
|
||||||
self.names_closure = names
|
self.names_closure = names
|
||||||
|
|
||||||
|
@attr.s
|
||||||
|
class DefinitionMock(object):
|
||||||
|
obj = attr.ib()
|
||||||
|
|
||||||
names = fixtures.getfuncargnames(func)
|
names = fixtures.getfuncargnames(func)
|
||||||
fixtureinfo = FixtureInfo(names)
|
fixtureinfo = FixtureInfo(names)
|
||||||
definition = python.FunctionDefinition(
|
definition = DefinitionMock(func)
|
||||||
name=func.__name__,
|
|
||||||
parent=None,
|
|
||||||
callobj=func,
|
|
||||||
)
|
|
||||||
return python.Metafunc(definition, fixtureinfo, config)
|
return python.Metafunc(definition, fixtureinfo, config)
|
||||||
|
|
||||||
def test_no_funcargs(self, testdir):
|
def test_no_funcargs(self, testdir):
|
||||||
|
|
Loading…
Reference in New Issue