diff --git a/CHANGELOG b/CHANGELOG index e4b7c3b73..497c4d939 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -56,6 +56,8 @@ Changes between 2.2.4 and 2.3.0.dev - fix issue 188: ensure sys.exc_info is clear on python2 before calling into a test +- fix issue 191: addd unittest TestCase runTest method support + - reporting refinements: - pytest_report_header now receives a "startdir" so that diff --git a/_pytest/unittest.py b/_pytest/unittest.py index 10b5c60a2..80343361b 100644 --- a/_pytest/unittest.py +++ b/_pytest/unittest.py @@ -34,6 +34,9 @@ class UnitTestCase(pytest.Class): pytest.mark.xfail(reason=str(funcobj.todo))(funcobj) yield TestCaseFunction(name, parent=self) + if getattr(self.obj, 'runTest', None) is not None: + yield TestCaseFunction('runTest', parent=self) + def setup(self): meth = getattr(self.obj, 'setUpClass', None) if meth is not None: diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 63e9cd89a..a699f4a23 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -14,6 +14,17 @@ def test_simple_unittest(testdir): assert reprec.matchreport("testpassing").passed assert reprec.matchreport("test_failing").failed +def test_runTest_method(testdir): + testpath=testdir.makepyfile(""" + import unittest + pytest_plugins = "pytest_unittest" + class MyTestCase(unittest.TestCase): + def runTest(self): + self.assertEquals('foo', 'foo') + """) + reprec = testdir.inline_run(testpath) + assert reprec.matchreport('runTest').passed + def test_isclasscheck_issue53(testdir): testpath = testdir.makepyfile(""" import unittest