fix reporting for @mock'd test functions

This commit is contained in:
holger krekel 2013-12-03 11:23:22 +01:00
parent 5dbf4fc0c2
commit d30ad3f5ce
3 changed files with 7 additions and 2 deletions

View File

@ -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
-----------------------------------

View File

@ -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

View File

@ -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")