Skip to content
Browse files

Remove the use of decorators and str.rsplit() from the xmlrunner code…

… to make it compatible with Python 2.3

Decorators were introduced in 2.4 (PEP 318), who knew!

Signed-off-by: R. Tyler Ballance <tyler@slide.com>
  • Loading branch information...
1 parent b20949d commit 65d86459549ac1a6d0b28fa4f64f6ef4925616ef R. Tyler Ballance committed
Showing with 22 additions and 22 deletions.
  1. +22 −22 src/Tests/xmlrunner.py
View
44 src/Tests/xmlrunner.py
@@ -19,6 +19,7 @@
from StringIO import StringIO
+
class _TestInfo(object):
"""Information about a particular test.
@@ -28,29 +29,12 @@ class _TestInfo(object):
"""
def __init__(self, test, time):
- (self._class, self._method) = test.id().rsplit(".", 1)
+ _pieces = test.id().split('.')
+ (self._class, self._method) = ('.'.join(_pieces[:-1]), _pieces[-1])
self._time = time
self._error = None
self._failure = None
- @staticmethod
- def create_success(test, time):
- """Create a _TestInfo instance for a successful test."""
- return _TestInfo(test, time)
-
- @staticmethod
- def create_failure(test, time, failure):
- """Create a _TestInfo instance for a failed test."""
- info = _TestInfo(test, time)
- info._failure = failure
- return info
-
- @staticmethod
- def create_error(test, time, error):
- """Create a _TestInfo instance for an erroneous test."""
- info = _TestInfo(test, time)
- info._error = error
- return info
def print_report(self, stream):
"""Print information about this test case in XML format to the
@@ -81,6 +65,22 @@ def _print_error(self, stream, tagname, error):
stream.write(' </%s>\n' % tagname)
stream.write(' ')
+# Module level functions since Python 2.3 doesn't grok decorators
+def create_success(test, time):
+ """Create a _TestInfo instance for a successful test."""
+ return _TestInfo(test, time)
+
+def create_failure(test, time, failure):
+ """Create a _TestInfo instance for a failed test."""
+ info = _TestInfo(test, time)
+ info._failure = failure
+ return info
+
+def create_error(test, time, error):
+ """Create a _TestInfo instance for an erroneous test."""
+ info = _TestInfo(test, time)
+ info._error = error
+ return info
class _XMLTestResult(unittest.TestResult):
@@ -108,11 +108,11 @@ def stopTest(self, test):
time_taken = time.time() - self._start_time
unittest.TestResult.stopTest(self, test)
if self._error:
- info = _TestInfo.create_error(test, time_taken, self._error)
+ info = create_error(test, time_taken, self._error)
elif self._failure:
- info = _TestInfo.create_failure(test, time_taken, self._failure)
+ info = create_failure(test, time_taken, self._failure)
else:
- info = _TestInfo.create_success(test, time_taken)
+ info = create_success(test, time_taken)
self._tests.append(info)
def addError(self, test, err):

0 comments on commit 65d8645

Please sign in to comment.
Something went wrong with that request. Please try again.