From d5c3265763ddca8bdbdbc39bf29028ce16423e38 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 18 Dec 2011 23:01:39 +0000 Subject: [PATCH] fix issue101: wrong args to unittest.TestCase test function now produce better output --- CHANGELOG | 3 +++ _pytest/__init__.py | 2 +- _pytest/unittest.py | 5 ++++- setup.py | 2 +- testing/test_unittest.py | 11 +++++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7cec8a45f..3248bcd87 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 ---------------------------------------- diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 62b131259..e9c53b63b 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '2.2.2.dev1' +__version__ = '2.2.2.dev2' diff --git a/_pytest/unittest.py b/_pytest/unittest.py index 2f04f334d..d4ca5575b 100644 --- a/_pytest/unittest.py +++ b/_pytest/unittest.py @@ -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): diff --git a/setup.py b/setup.py index db275ebd9..afa397e4d 100644 --- a/setup.py +++ b/setup.py @@ -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'], diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 2abf8b49d..aba17cc7e 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -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