From 99015bfc86d6ad309bdd9abbe2c0700d58ca36d1 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sat, 17 Mar 2018 22:04:22 +0100 Subject: [PATCH] fix most of metafunc tests by mocking --- _pytest/python.py | 2 +- testing/python/metafunc.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/_pytest/python.py b/_pytest/python.py index 843d7f534..e33de018e 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -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 diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index b65a42e09..9b70c3305 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import re import sys - +import attr import _pytest._code import py import pytest @@ -24,13 +24,13 @@ class TestMetafunc(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):