Merge lp:~gmb/zope.testing/fix-skips into lp:~launchpad/zope.testing/3.9.4-fork

Proposed by Graham Binns
Status: Merged
Approved by: Graham Binns
Approved revision: 48
Merged at revision: 48
Proposed branch: lp:~gmb/zope.testing/fix-skips
Merge into: lp:~launchpad/zope.testing/3.9.4-fork
Diff against target: 39 lines (+10/-1)
2 files modified
src/zope/testing/testrunner/runner.py (+5/-1)
src/zope/testing/testrunner/test_testresult.py (+5/-0)
To merge this branch: bzr merge lp:~gmb/zope.testing/fix-skips
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Review via email: mp+113562@code.launchpad.net

Commit message

Update the handling of addSkip() to take account of the fact that such functionality doesn't exist in Python 2.6.

Description of the change

This branch fixes skips when using Python 2.6.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

Self-reviewing for the sake of speed.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/zope/testing/testrunner/runner.py'
--- src/zope/testing/testrunner/runner.py 2012-06-29 12:26:22 +0000
+++ src/zope/testing/testrunner/runner.py 2012-07-05 12:07:23 +0000
@@ -795,7 +795,11 @@
795 self._start_time = time.time()795 self._start_time = time.time()
796796
797 def addSkip(self, test, reason):797 def addSkip(self, test, reason):
798 unittest.TestResult.addSkip(self, test, reason)798 if hasattr(unittest.TestResult, 'addSkip'):
799 # Python 2.6's unittest.TestResult has no concept of
800 # skipping, so we only call up to the parent class if doing
801 # so won't cause an error.
802 unittest.TestResult.addSkip(self, test, reason)
799 self.options.output.test_skip(test, reason)803 self.options.output.test_skip(test, reason)
800804
801 def addSuccess(self, test):805 def addSuccess(self, test):
802806
=== modified file 'src/zope/testing/testrunner/test_testresult.py'
--- src/zope/testing/testrunner/test_testresult.py 2012-06-29 13:40:49 +0000
+++ src/zope/testing/testrunner/test_testresult.py 2012-07-05 12:07:23 +0000
@@ -16,6 +16,7 @@
1616
17__metaclass__ = type17__metaclass__ = type
1818
19import sys
19import unittest20import unittest
20from StringIO import StringIO21from StringIO import StringIO
2122
@@ -90,6 +91,10 @@
90 def test_addSkip_appends_skipped_test_to_skipped(self):91 def test_addSkip_appends_skipped_test_to_skipped(self):
91 # TestResult.addSkip() appends the skipped test to the92 # TestResult.addSkip() appends the skipped test to the
92 # TestResult's skipped attribute.93 # TestResult's skipped attribute.
94 # This test is only run under Python 2.7; skips don't exist in
95 # Python 2.6.
96 if sys.version_info[:-3] < (2, 7):
97 return
93 test = self.example_suite._tests[0]98 test = self.example_suite._tests[0]
94 self.result.addSkip(test, "Testing")99 self.result.addSkip(test, "Testing")
95 self.assertIn((test, "Testing"), self.result.skipped)100 self.assertIn((test, "Testing"), self.result.skipped)

Subscribers

People subscribed via source and target branches