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
1=== modified file 'src/zope/testing/testrunner/runner.py'
2--- src/zope/testing/testrunner/runner.py 2012-06-29 12:26:22 +0000
3+++ src/zope/testing/testrunner/runner.py 2012-07-05 12:07:23 +0000
4@@ -795,7 +795,11 @@
5 self._start_time = time.time()
6
7 def addSkip(self, test, reason):
8- unittest.TestResult.addSkip(self, test, reason)
9+ if hasattr(unittest.TestResult, 'addSkip'):
10+ # Python 2.6's unittest.TestResult has no concept of
11+ # skipping, so we only call up to the parent class if doing
12+ # so won't cause an error.
13+ unittest.TestResult.addSkip(self, test, reason)
14 self.options.output.test_skip(test, reason)
15
16 def addSuccess(self, test):
17
18=== modified file 'src/zope/testing/testrunner/test_testresult.py'
19--- src/zope/testing/testrunner/test_testresult.py 2012-06-29 13:40:49 +0000
20+++ src/zope/testing/testrunner/test_testresult.py 2012-07-05 12:07:23 +0000
21@@ -16,6 +16,7 @@
22
23 __metaclass__ = type
24
25+import sys
26 import unittest
27 from StringIO import StringIO
28
29@@ -90,6 +91,10 @@
30 def test_addSkip_appends_skipped_test_to_skipped(self):
31 # TestResult.addSkip() appends the skipped test to the
32 # TestResult's skipped attribute.
33+ # This test is only run under Python 2.7; skips don't exist in
34+ # Python 2.6.
35+ if sys.version_info[:-3] < (2, 7):
36+ return
37 test = self.example_suite._tests[0]
38 self.result.addSkip(test, "Testing")
39 self.assertIn((test, "Testing"), self.result.skipped)

Subscribers

People subscribed via source and target branches