unittest plugin: prune __unittest marked modules from traces
This commit is contained in:
parent
7e44c38570
commit
a6c518e68c
|
@ -102,6 +102,10 @@ class TestCaseFunction(pytest.Function):
|
|||
def runtest(self):
|
||||
self._testcase(result=self)
|
||||
|
||||
def _prunetraceback(self, excinfo):
|
||||
pytest.Function._prunetraceback(self, excinfo)
|
||||
excinfo.traceback = excinfo.traceback.filter(lambda x:not x.frame.f_globals.get('__unittest'))
|
||||
|
||||
@pytest.mark.tryfirst
|
||||
def pytest_runtest_makereport(item, call):
|
||||
if isinstance(item, TestCaseFunction):
|
||||
|
|
|
@ -396,3 +396,15 @@ def test_djangolike_testcase(testdir):
|
|||
"*tearDown()*",
|
||||
"*_post_teardown()*",
|
||||
])
|
||||
|
||||
|
||||
def test_unittest_not_shown_in_traceback(testdir):
|
||||
testdir.makepyfile("""
|
||||
import unittest
|
||||
class t(unittest.TestCase):
|
||||
def test_hello(self):
|
||||
x = 3
|
||||
self.assertEquals(x, 4)
|
||||
""")
|
||||
res = testdir.runpytest()
|
||||
assert "failUnlessEqual" not in res.stdout.str()
|
||||
|
|
Loading…
Reference in New Issue