# TODO: simplify javascript using ,ore than 1 class in the class attribute?
import datetime
-import StringIO
+try:
+ from StringIO import StringIO
+except ImportError:
+ from io import StringIO
import sys
import time
import unittest
def startTest(self, test):
TestResult.startTest(self, test)
# just one buffer for both stdout and stderr
- self.outputBuffer = StringIO.StringIO()
+ self.outputBuffer = StringIO()
stdout_redirector.fp = self.outputBuffer
stderr_redirector.fp = self.outputBuffer
self.stdout0 = sys.stdout
test(result)
self.stopTime = datetime.datetime.now()
self.generateReport(test, result)
- print >>sys.stderr, '\nTime Elapsed: %s' % (self.stopTime-self.startTime)
+ print ("\nTime Elapsed: %s" %(self.stopTime-self.startTime),
+ file=sys.stderr)
return result
classes = []
for n,t,o,e in result_list:
cls = t.__class__
- if not rmap.has_key(cls):
+ if not cls in rmap:
rmap[cls] = []
classes.append(cls)
rmap[cls].append((n,t,o,e))
report = report,
ending = ending,
)
- self.stream.write(output.encode('utf8'))
+ self.stream.write(output)
def _generate_stylesheet(self):
if isinstance(o,str):
# TODO: some problem with 'string_escape': it escape \n and mess up formating
# uo = unicode(o.encode('string_escape'))
- uo = o.decode('latin-1')
+ uo = bytes(o, 'utf-8').decode('latin-1')
else:
uo = o
if isinstance(e,str):
# TODO: some problem with 'string_escape': it escape \n and mess up formating
# ue = unicode(e.encode('string_escape'))
- ue = e.decode('latin-1')
+ ue = bytes(e, 'utf-8').decode('latin-1')
else:
ue = e