From d30ad3f5cee664f75cae0a134a75a55cde3a0354 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 3 Dec 2013 11:23:22 +0100 Subject: [PATCH] fix reporting for @mock'd test functions --- CHANGELOG | 2 ++ _pytest/python.py | 3 +-- testing/python/integration.py | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5643224d2..65e0f5435 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -88,6 +88,8 @@ Unreleased - fix issue377 by clarifying in the nose-compat docs that pytest does not duplicate the unittest-API into the "plain" namespace. +- fix verbose reporting for @mock'd test functions + Changes between 2.4.1 and 2.4.2 ----------------------------------- diff --git a/_pytest/python.py b/_pytest/python.py index a319e3ea8..eeaa13ec9 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -277,10 +277,9 @@ class PyobjMixin(PyobjContext): if fspath.endswith(".pyc"): fspath = fspath[:-1] lineno = obj.compat_co_firstlineno - modpath = obj.__module__ else: fspath, lineno = getfslineno(obj) - modpath = self.getmodpath() + modpath = self.getmodpath() assert isinstance(lineno, int) return fspath, lineno, modpath diff --git a/testing/python/integration.py b/testing/python/integration.py index 60002b83f..6fbf44572 100644 --- a/testing/python/integration.py +++ b/testing/python/integration.py @@ -133,6 +133,10 @@ class TestMockDecoration: """) reprec = testdir.inline_run() reprec.assertoutcome(passed=2) + calls = reprec.getcalls("pytest_runtest_logreport") + funcnames = [call.report.location[2] for call in calls + if call.report.when == "call"] + assert funcnames == ["T.test_hello", "test_someting"] def test_mock_sorting(self, testdir): pytest.importorskip("mock", "1.0.1")