[py-svn] commit/pytest: RonnyPfannschmidt: fix issue 191 - add support for runTest method of unittest.TestCase subclasses
Bitbucket
commits-noreply at bitbucket.org
Sat Sep 22 18:25:04 CEST 2012
1 new commit in pytest:
https://bitbucket.org/hpk42/pytest/changeset/3a876497815d/
changeset: 3a876497815d
user: RonnyPfannschmidt
date: 2012-09-22 18:24:53
summary: fix issue 191 - add support for runTest method of unittest.TestCase subclasses
affected #: 3 files
diff -r 5083259b34c8ac69d12243d73451d2e2f3a720ab -r 3a876497815d887f3c13589aa81b238e8bee3b1e CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -56,6 +56,8 @@
- 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 -r 5083259b34c8ac69d12243d73451d2e2f3a720ab -r 3a876497815d887f3c13589aa81b238e8bee3b1e _pytest/unittest.py
--- a/_pytest/unittest.py
+++ b/_pytest/unittest.py
@@ -34,6 +34,9 @@
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 -r 5083259b34c8ac69d12243d73451d2e2f3a720ab -r 3a876497815d887f3c13589aa81b238e8bee3b1e testing/test_unittest.py
--- a/testing/test_unittest.py
+++ b/testing/test_unittest.py
@@ -14,6 +14,17 @@
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
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