Rev 4066: Python2.4 compatibility. in http://people.ubuntu.com/~robertc/baz2.0/integration
Robert Collins
robertc at robertcollins.net
Sun Mar 1 11:11:17 GMT 2009
At http://people.ubuntu.com/~robertc/baz2.0/integration
------------------------------------------------------------
revno: 4066
revision-id: robertc at robertcollins.net-20090301111114-jupiev5u7eog3b52
parent: robertc at robertcollins.net-20090301095707-w52moizbku399auj
committer: Robert Collins <robertc at robertcollins.net>
branch nick: integration
timestamp: Sun 2009-03-01 22:11:14 +1100
message:
Python2.4 compatibility.
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2009-03-01 09:57:07 +0000
+++ b/bzrlib/tests/__init__.py 2009-03-01 11:11:14 +0000
@@ -300,7 +300,7 @@
except KeyboardInterrupt:
raise
except:
- self.addError(test, test._exc_info())
+ self.addError(test, test.exc_info())
else:
# seems best to treat this as success from point-of-view of unittest
# -- it actually does nothing so it barely matters :)
@@ -776,6 +776,13 @@
TestCase._active_threads = threading.activeCount()
self.addCleanup(self._check_leaked_threads)
+ def exc_info(self):
+ absent_attr = object()
+ exc_info = getattr(self, '_exc_info', absent_attr)
+ if exc_info is absent_attr:
+ exc_info = getattr(self, '_TestCase__exc_info')
+ return exc_info()
+
def _check_leaked_threads(self):
active = threading.activeCount()
leaked_threads = active - TestCase._active_threads
@@ -1286,7 +1293,7 @@
def _do_skip(self, result, reason):
addSkip = getattr(result, 'addSkip', None)
if not callable(addSkip):
- result.addError(self, self._exc_info())
+ result.addError(self, self.exc_info())
else:
addSkip(self, reason)
@@ -1304,7 +1311,13 @@
try:
try:
result.startTest(self)
- testMethod = getattr(self, self._testMethodName)
+ absent_attr = object()
+ # Python 2.5
+ method_name = getattr(self, '_testMethodName', absent_attr)
+ if method_name is absent_attr:
+ # Python 2.4
+ method_name = getattr(self, '_TestCase__testMethodName')
+ testMethod = getattr(self, method_name)
try:
try:
self.setUp()
@@ -1315,7 +1328,7 @@
self.tearDown()
return
except:
- result.addError(self, self._exc_info())
+ result.addError(self, self.exc_info())
return
ok = False
@@ -1323,7 +1336,7 @@
testMethod()
ok = True
except self.failureException:
- result.addFailure(self, self._exc_info())
+ result.addFailure(self, self.exc_info())
except TestSkipped, e:
if not e.args:
reason = "No reason given."
@@ -1333,14 +1346,14 @@
except KeyboardInterrupt:
raise
except:
- result.addError(self, self._exc_info())
+ result.addError(self, self.exc_info())
try:
self.tearDown()
except KeyboardInterrupt:
raise
except:
- result.addError(self, self._exc_info())
+ result.addError(self, self.exc_info())
ok = False
if ok: result.addSuccess(self)
finally:
More information about the bazaar-commits
mailing list