Browse Source

gunittest: when printing, it should be 'str' in py 2 and 3

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74500 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 6 years ago
parent
commit
4f2c2421e3
1 changed files with 9 additions and 9 deletions
  1. 9 9
      lib/python/gunittest/case.py

+ 9 - 9
lib/python/gunittest/case.py

@@ -19,7 +19,7 @@ import unittest
 
 
 from grass.pygrass.modules import Module
 from grass.pygrass.modules import Module
 from grass.exceptions import CalledModuleError
 from grass.exceptions import CalledModuleError
-from grass.script import shutil_which
+from grass.script import shutil_which, text_to_string
 
 
 from .gmodules import call_module, SimpleModule
 from .gmodules import call_module, SimpleModule
 from .checkers import (check_text_ellipsis,
 from .checkers import (check_text_ellipsis,
@@ -1149,8 +1149,8 @@ class TestCase(unittest.TestCase):
             module.run()
             module.run()
             self.grass_modules.append(module.name)
             self.grass_modules.append(module.name)
         except CalledModuleError:
         except CalledModuleError:
-            print(module.outputs.stdout)
-            print(module.outputs.stderr)
+            print(text_to_string(module.outputs.stdout))
+            print(text_to_string(module.outputs.stderr))
             # TODO: message format
             # TODO: message format
             # TODO: stderr?
             # TODO: stderr?
             stdmsg = ('Running <{m.name}> module ended'
             stdmsg = ('Running <{m.name}> module ended'
@@ -1162,8 +1162,8 @@ class TestCase(unittest.TestCase):
                           errors=module.outputs.stderr
                           errors=module.outputs.stderr
                       ))
                       ))
             self.fail(self._formatMessage(msg, stdmsg))
             self.fail(self._formatMessage(msg, stdmsg))
-        print(module.outputs.stdout)
-        print(module.outputs.stderr)
+        print(text_to_string(module.outputs.stdout))
+        print(text_to_string(module.outputs.stderr))
         # log these to final report
         # log these to final report
         # TODO: always or only if the calling test method failed?
         # TODO: always or only if the calling test method failed?
         # in any case, this must be done before self.fail()
         # in any case, this must be done before self.fail()
@@ -1183,11 +1183,11 @@ class TestCase(unittest.TestCase):
             module.run()
             module.run()
             self.grass_modules.append(module.name)
             self.grass_modules.append(module.name)
         except CalledModuleError:
         except CalledModuleError:
-            print(module.outputs.stdout)
-            print(module.outputs.stderr)
+            print(text_to_string(module.outputs.stdout))
+            print(text_to_string(module.outputs.stderr))
         else:
         else:
-            print(module.outputs.stdout)
-            print(module.outputs.stderr)
+            print(text_to_string(module.outputs.stdout))
+            print(text_to_string(module.outputs.stderr))
             stdmsg = ('Running <%s> ended with zero (successful) return code'
             stdmsg = ('Running <%s> ended with zero (successful) return code'
                       ' when expecting module to fail' % module.get_python())
                       ' when expecting module to fail' % module.get_python())
             self.fail(self._formatMessage(msg, stdmsg))
             self.fail(self._formatMessage(msg, stdmsg))