[Pytest-commit] commit/pytest: hpk42: fix reporting for @mock'd test functions

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Dec 3 11:23:29 CET 2013


1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/a6837c60c240/
Changeset:   a6837c60c240
User:        hpk42
Date:        2013-12-03 11:23:22
Summary:     fix reporting for @mock'd test functions
Affected #:  3 files

diff -r 81afec2afcbf5d2c7e5d31ed3a35a7dd0b654820 -r a6837c60c2409e26e718c20a5e033842afe73a0f CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -88,6 +88,8 @@
 - 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 -r 81afec2afcbf5d2c7e5d31ed3a35a7dd0b654820 -r a6837c60c2409e26e718c20a5e033842afe73a0f _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -277,10 +277,9 @@
             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 -r 81afec2afcbf5d2c7e5d31ed3a35a7dd0b654820 -r a6837c60c2409e26e718c20a5e033842afe73a0f testing/python/integration.py
--- a/testing/python/integration.py
+++ b/testing/python/integration.py
@@ -133,6 +133,10 @@
         """)
         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")

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the pytest-commit mailing list