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

Proposed by Graham Binns
Status: Merged
Approved by: Graham Binns
Approved revision: 52
Merged at revision: 49
Proposed branch: lp:~gmb/zope.testing/argh-argh-argh
Merge into: lp:~launchpad/zope.testing/3.9.4-fork
Diff against target: 109 lines (+34/-9)
3 files modified
setup.py (+1/-1)
src/zope/testing/testrunner/runner.py (+6/-4)
src/zope/testing/testrunner/test_testresult.py (+27/-4)
To merge this branch: bzr merge lp:~gmb/zope.testing/argh-argh-argh
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+113586@code.launchpad.net

Commit message

Update our Python 2.7-compatible code so that it falls back to existing behaviour when run under 2.6. Also bump the patch number to avoid anyone with a stale bad version of p16 in their download-cache from getting knobbled.

Description of the change

This branch tweaks our Python 2.7 compatibility code so that it doesn't break the test suite under Python 2.6.

Previously, we allowed addSkip() to do its thing under Python 2.6. aside from calling up to its parent class. However, existing behaviour is to just call addSuccess() when skipping tests under 2.6, so we decided to preserve that behaviour.

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

This branch looks good. I think you have a typo, shouldn't "2.6" be "2.7" in the below comment?

    # This test can go away once we're only using Python 2.6

review: Approve (code)
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'setup.py'
--- setup.py 2012-06-29 13:43:07 +0000
+++ setup.py 2012-07-05 14:28:32 +0000
@@ -85,7 +85,7 @@
8585
86setup(86setup(
87 name='zope.testing',87 name='zope.testing',
88 version = '3.9.4-p16',88 version = '3.9.4-p17',
89 url='http://pypi.python.org/pypi/zope.testing',89 url='http://pypi.python.org/pypi/zope.testing',
90 license='ZPL 2.1',90 license='ZPL 2.1',
91 description='Zope testing framework, including the testrunner script.',91 description='Zope testing framework, including the testrunner script.',
9292
=== modified file 'src/zope/testing/testrunner/runner.py'
--- src/zope/testing/testrunner/runner.py 2012-07-05 12:03:23 +0000
+++ src/zope/testing/testrunner/runner.py 2012-07-05 14:28:32 +0000
@@ -795,12 +795,14 @@
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 if hasattr(unittest.TestResult, 'addSkip'):798 if sys.version_info[:-3] < (2, 7):
799 # Python 2.6's unittest.TestResult has no concept of799 # Python 2.6's unittest.TestResult has no concept of
800 # skipping, so we only call up to the parent class if doing800 # skipping, so we fall back to addSuccess() if we're running
801 # so won't cause an error.801 # under Python < 2.7.
802 self.addSuccess(test)
803 else:
802 unittest.TestResult.addSkip(self, test, reason)804 unittest.TestResult.addSkip(self, test, reason)
803 self.options.output.test_skip(test, reason)805 self.options.output.test_skip(test, reason)
804806
805 def addSuccess(self, test):807 def addSuccess(self, test):
806 t = max(time.time() - self._start_time, 0.0)808 t = max(time.time() - self._start_time, 0.0)
807809
=== modified file 'src/zope/testing/testrunner/test_testresult.py'
--- src/zope/testing/testrunner/test_testresult.py 2012-07-05 12:03:23 +0000
+++ src/zope/testing/testrunner/test_testresult.py 2012-07-05 14:28:32 +0000
@@ -17,6 +17,7 @@
17__metaclass__ = type17__metaclass__ = type
1818
19import sys19import sys
20import time
20import unittest21import unittest
21from StringIO import StringIO22from StringIO import StringIO
2223
@@ -31,10 +32,14 @@
3132
32 def __init__(self):33 def __init__(self):
33 self.test_skip_called = False34 self.test_skip_called = False
35 self.test_success_called = False
3436
35 def test_skip(self, test, reason):37 def test_skip(self, test, reason):
36 self.test_skip_called = True38 self.test_skip_called = True
3739
40 def test_success(self, test, t):
41 self.test_success_called = True
42
3843
39class MockOptions:44class MockOptions:
4045
@@ -81,24 +86,42 @@
81 options, tests=[self.example_suite],86 options, tests=[self.example_suite],
82 layer_name="zope.testing.testrunner.test_testresult.TestLayer")87 layer_name="zope.testing.testrunner.test_testresult.TestLayer")
8388
84 def test_addSkip_calls_test_skip_on_output(self):89 def test_addSkip_calls_test_skip_on_output_in_python27(self):
85 # TestResult.addSkip() calls the test_skip() method on whatever90 # TestResult.addSkip() calls the test_skip() method on whatever
86 # it has as an output formatter.91 # it has as an output formatter.
92 # XXX 2012-07-05 gmb:
93 # This test is only run under Python 2.7; skips don't exist
94 # in Python 2.6.
95 if sys.version_info[:-3] < (2, 7):
96 return
87 test = self.example_suite._tests[0]97 test = self.example_suite._tests[0]
88 self.result.addSkip(test, "Testing")98 self.result.addSkip(test, "Testing")
89 self.assertTrue(self.output.test_skip_called)99 self.assertTrue(self.output.test_skip_called)
90100
91 def test_addSkip_appends_skipped_test_to_skipped(self):101 def test_addSkip_appends_skipped_test_to_skipped_in_python27(self):
92 # TestResult.addSkip() appends the skipped test to the102 # TestResult.addSkip() appends the skipped test to the
93 # TestResult's skipped attribute.103 # TestResult's skipped attribute.
94 # This test is only run under Python 2.7; skips don't exist in104 # XXX 2012-07-05 gmb:
95 # Python 2.6.105 # This test is only run under Python 2.7; skips don't exist
106 # in Python 2.6.
96 if sys.version_info[:-3] < (2, 7):107 if sys.version_info[:-3] < (2, 7):
97 return108 return
98 test = self.example_suite._tests[0]109 test = self.example_suite._tests[0]
99 self.result.addSkip(test, "Testing")110 self.result.addSkip(test, "Testing")
100 self.assertIn((test, "Testing"), self.result.skipped)111 self.assertIn((test, "Testing"), self.result.skipped)
101112
113 # XXX 2012-07-05 gmb:
114 # This test can go away once we're only using Python 2.7.
115 def test_addSkip_calls_addSuccess_under_python26(self):
116 # When running under Python 2.6, addSkip() calls addSuccess(),
117 # since skips aren't supported under Python 2.6
118 if sys.version_info[:-3] > (2, 6):
119 self.skipTest("Test is Python 2.6-specific.")
120 test = self.example_suite._tests[0]
121 self.result._start_time = time.time()
122 self.result.addSkip(test, "Testing")
123 self.assertTrue(self.output.test_success_called)
124
102125
103class TestOutputFormatters(unittest.TestCase):126class TestOutputFormatters(unittest.TestCase):
104 """Tests for the handling of test_skip by different output formatters."""127 """Tests for the handling of test_skip by different output formatters."""

Subscribers

People subscribed via source and target branches