fix reporting for @mock'd test functions
This commit is contained in:
parent
5dbf4fc0c2
commit
d30ad3f5ce
|
@ -88,6 +88,8 @@ Unreleased
|
||||||
- fix issue377 by clarifying in the nose-compat docs that pytest
|
- fix issue377 by clarifying in the nose-compat docs that pytest
|
||||||
does not duplicate the unittest-API into the "plain" namespace.
|
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
|
Changes between 2.4.1 and 2.4.2
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
|
|
@ -277,10 +277,9 @@ class PyobjMixin(PyobjContext):
|
||||||
if fspath.endswith(".pyc"):
|
if fspath.endswith(".pyc"):
|
||||||
fspath = fspath[:-1]
|
fspath = fspath[:-1]
|
||||||
lineno = obj.compat_co_firstlineno
|
lineno = obj.compat_co_firstlineno
|
||||||
modpath = obj.__module__
|
|
||||||
else:
|
else:
|
||||||
fspath, lineno = getfslineno(obj)
|
fspath, lineno = getfslineno(obj)
|
||||||
modpath = self.getmodpath()
|
modpath = self.getmodpath()
|
||||||
assert isinstance(lineno, int)
|
assert isinstance(lineno, int)
|
||||||
return fspath, lineno, modpath
|
return fspath, lineno, modpath
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,10 @@ class TestMockDecoration:
|
||||||
""")
|
""")
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=2)
|
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):
|
def test_mock_sorting(self, testdir):
|
||||||
pytest.importorskip("mock", "1.0.1")
|
pytest.importorskip("mock", "1.0.1")
|
||||||
|
|
Loading…
Reference in New Issue