fix issue101: wrong args to unittest.TestCase test function now

produce better output
This commit is contained in:
holger krekel 2011-12-18 23:01:39 +00:00
parent 13e0340350
commit d5c3265763
5 changed files with 20 additions and 3 deletions

View File

@ -3,6 +3,9 @@ Changes between 2.2.1 and 2.2.2.dev
- make monkeypatch more robust against intermediate dict/env deletions
- use distribute_setup script defaulting to 0.6.24 if no setuptools is installed
- fix issue101: wrong args to unittest.TestCase test function now
produce better output
Changes between 2.2.0 and 2.2.1
----------------------------------------

View File

@ -1,2 +1,2 @@
#
__version__ = '2.2.2.dev1'
__version__ = '2.2.2.dev2'

View File

@ -108,7 +108,10 @@ class TestCaseFunction(pytest.Function):
def _prunetraceback(self, excinfo):
pytest.Function._prunetraceback(self, excinfo)
excinfo.traceback = excinfo.traceback.filter(lambda x:not x.frame.f_globals.get('__unittest'))
traceback = excinfo.traceback.filter(
lambda x:not x.frame.f_globals.get('__unittest'))
if traceback:
excinfo.traceback = traceback
@pytest.mark.tryfirst
def pytest_runtest_makereport(item, call):

View File

@ -24,7 +24,7 @@ def main():
name='pytest',
description='py.test: simple powerful testing with Python',
long_description = long_description,
version='2.2.2.dev1',
version='2.2.2.dev2',
url='http://pytest.org',
license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

View File

@ -448,3 +448,14 @@ def test_unorderable_types(testdir):
result = testdir.runpytest()
assert "TypeError" not in result.stdout.str()
assert result.ret == 0
def test_unittest_typerror_traceback(testdir):
testdir.makepyfile("""
import unittest
class TestJoinEmpty(unittest.TestCase):
def test_hello(self, arg1):
pass
""")
result = testdir.runpytest()
assert "TypeError" in result.stdout.str()
assert result.ret == 1