]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
Py3 porting. NOTE: may not be Py2 compliant anymore => to be done
authorSimon Pomarede <simon.pomarede@cea.fr>
Thu, 4 Feb 2016 13:32:08 +0000 (14:32 +0100)
committerSimon Pomarede <simon.pomarede@cea.fr>
Thu, 4 Feb 2016 13:32:08 +0000 (14:32 +0100)
test/_testTools/HTMLTestRunner.py

index 0439bf488b144a5f5c670fbe057d9a36f44915e4..1ace9626cb628c8385e11db929071a6d80e0549d 100644 (file)
@@ -91,7 +91,10 @@ Version in 0.7.1
 # 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
@@ -536,7 +539,7 @@ class _TestResult(TestResult):
     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
@@ -628,7 +631,8 @@ class HTMLTestRunner(Template_mixin):
         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
 
 
@@ -639,7 +643,7 @@ class HTMLTestRunner(Template_mixin):
         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))
@@ -684,7 +688,7 @@ class HTMLTestRunner(Template_mixin):
             report = report,
             ending = ending,
         )
-        self.stream.write(output.encode('utf8'))
+        self.stream.write(output)
 
 
     def _generate_stylesheet(self):
@@ -763,13 +767,13 @@ class HTMLTestRunner(Template_mixin):
         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