Merge lp:~lifeless/testtools/2.4 into lp:~testtools-committers/testtools/trunk

Proposed by Robert Collins
Status: Merged
Merged at revision: not available
Proposed branch: lp:~lifeless/testtools/2.4
Merge into: lp:~testtools-committers/testtools/trunk
Diff against target: 102 lines (+37/-9)
3 files modified
NEWS (+15/-0)
testtools/testcase.py (+19/-6)
testtools/tests/test_testtools.py (+3/-3)
To merge this branch: bzr merge lp:~lifeless/testtools/2.4
Reviewer Review Type Date Requested Status
Jonathan Lange Approve
Review via email: mp+15300@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

2.4. \o/

Revision history for this message
Jonathan Lange (jml) wrote :

Rock and roll.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2009-11-21 19:24:13 +0000
3+++ NEWS 2009-11-27 00:50:27 +0000
4@@ -1,6 +1,21 @@
5 testtools NEWS
6 ==============
7
8+NEXT
9+~~~~
10+
11+Changes
12+-------
13+
14+* TestCase.getUniqueString now uses the test id, not the test method name,
15+ which works nicer with parameterised tests.
16+
17+Improvements
18+------------
19+
20+* Python2.4 is now supported again.
21+
22+
23 0.9.0
24 ~~~~~
25
26
27=== modified file 'testtools/testcase.py'
28--- testtools/testcase.py 2009-11-20 00:46:00 +0000
29+++ testtools/testcase.py 2009-11-27 00:50:27 +0000
30@@ -12,7 +12,10 @@
31 ]
32
33 from copy import deepcopy
34-import functools
35+try:
36+ from functools import wraps
37+except ImportError:
38+ wraps = None
39 import sys
40 import unittest
41
42@@ -228,7 +231,7 @@
43 return self._last_unique_id
44
45 def getUniqueString(self):
46- return '%s-%d' % (self._testMethodName, self.getUniqueInteger())
47+ return '%s-%d' % (self.id(), self.getUniqueInteger())
48
49 def _report_error(self, result):
50 self._report_traceback()
51@@ -251,7 +254,13 @@
52 result = self.defaultTestResult()
53 result = ExtendedToOriginalDecorator(result)
54 result.startTest(self)
55- testMethod = getattr(self, self._testMethodName)
56+ absent_attr = object()
57+ # Python 2.5
58+ method_name = getattr(self, '_testMethodName', absent_attr)
59+ if method_name is absent_attr:
60+ # Python 2.4
61+ method_name = getattr(self, '_TestCase__testMethodName')
62+ testMethod = getattr(self, method_name)
63 try:
64 try:
65 self.setUp()
66@@ -338,9 +347,13 @@
67 @unittest.skip decorator.
68 """
69 def decorator(test_item):
70- @functools.wraps(test_item)
71- def skip_wrapper(*args, **kwargs):
72- raise TestCase.skipException(reason)
73+ if wraps is not None:
74+ @wraps(test_item)
75+ def skip_wrapper(*args, **kwargs):
76+ raise TestCase.skipException(reason)
77+ else:
78+ def skip_wrapper(test_item):
79+ test_item.skip(reason)
80 return skip_wrapper
81 return decorator
82
83
84=== modified file 'testtools/tests/test_testtools.py'
85--- testtools/tests/test_testtools.py 2009-11-19 10:56:58 +0000
86+++ testtools/tests/test_testtools.py 2009-11-27 00:50:27 +0000
87@@ -491,12 +491,12 @@
88 self.assertEqual(2, two)
89
90 def test_getUniqueString(self):
91- # getUniqueString returns the current test name followed by a unique
92+ # getUniqueString returns the current test id followed by a unique
93 # integer.
94 name_one = self.getUniqueString()
95- self.assertEqual('%s-%d' % (self._testMethodName, 1), name_one)
96+ self.assertEqual('%s-%d' % (self.id(), 1), name_one)
97 name_two = self.getUniqueString()
98- self.assertEqual('%s-%d' % (self._testMethodName, 2), name_two)
99+ self.assertEqual('%s-%d' % (self.id(), 2), name_two)
100
101
102 class TestCloneTestWithNewId(TestCase):

Subscribers

People subscribed via source and target branches