Skip to content

Commit

Permalink
Completely use the unittest module from Django which is unittest2 in …
Browse files Browse the repository at this point in the history
…trunk and would break the test runner due to different code origins if mixed with unittest symbols.
  • Loading branch information
jezdez committed Oct 17, 2010
1 parent 76bd467 commit 35a1c15
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/test_extensions/testrunners/xmloutput.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import time, traceback, string
from unittest import TestResult

from xmlunit.unittest import _WritelnDecorator, XmlTextTestRunner as his_XmlTextTestRunner

Expand All @@ -9,10 +8,8 @@

try:
class XMLTestSuiteRunner(DjangoTestSuiteRunner):

def run_suite(self, suite, **kwargs):
return XMLTestRunner(verbosity=self.verbosity).run(suite)

except NameError: # DjangoTestSuiteRunner is not available in Django < 1.2
pass

Expand Down Expand Up @@ -59,7 +56,7 @@ class _XmlTextTestResult(unittest.TestResult):
#separator1 = '=' * 70
#separator2 = '-' * 70
def __init__(self, stream, descriptions, verbosity):
TestResult.__init__(self)
unittest.TestResult.__init__(self)
self.stream = _WritelnDecorator(stream)
self.showAll = verbosity > 1
self.descriptions = descriptions
Expand All @@ -78,7 +75,7 @@ def startTest(self, test): # CONSIDER why are there 2 startTests in here?
self._startTime = time.time()
test._extraXML = ''
test._extraAssertions = []
TestResult.startTest(self, test)
unittest.TestResult.startTest(self, test)
self.stream.write('<testcase classname="%s' % test.__class__.__name__ + '" name="%s' % test.id().split('.')[-1] + '"')
desc = test.shortDescription()

Expand All @@ -89,7 +86,7 @@ def startTest(self, test): # CONSIDER why are there 2 startTests in here?
def stopTest(self, test):
stopTime = time.time()
deltaTime = stopTime - self._startTime
TestResult.stopTest(self, test)
unittest.TestResult.stopTest(self, test)
self.stream.write(' time="%.3f"' % deltaTime)
self.stream.write('>')
if self._lastWas != 'success':
Expand Down Expand Up @@ -118,11 +115,11 @@ def _addAssertion(self, diagnostic):
self.stream.write('<assert>' + diagnostic + '</assert>')

def addSuccess(self, test):
TestResult.addSuccess(self, test)
unittest.TestResult.addSuccess(self, test)
self._lastWas = 'success'

def addError(self, test, err):
TestResult.addError(self, test, err)
unittest.TestResult.addError(self, test, err)
if err[0] is KeyboardInterrupt:
self.shouldStop = 1
self._lastWas = 'error'
Expand All @@ -133,7 +130,7 @@ def addError(self, test, err):
self._errorsAndFailures += "</error>"

def addFailure(self, test, err):
TestResult.addFailure(self, test, err)
unittest.TestResult.addFailure(self, test, err)
if err[0] is KeyboardInterrupt:
self.shouldStop = 1
self._lastWas = 'failure'
Expand Down

0 comments on commit 35a1c15

Please sign in to comment.