[GRASS-SVN] r74500 - grass/trunk/lib/python/gunittest

svn_grass at osgeo.org svn_grass at osgeo.org
Thu May 16 09:32:21 PDT 2019


Author: annakrat
Date: 2019-05-16 09:32:21 -0700 (Thu, 16 May 2019)
New Revision: 74500

Modified:
   grass/trunk/lib/python/gunittest/case.py
Log:
gunittest: when printing, it should be 'str' in py 2 and 3

Modified: grass/trunk/lib/python/gunittest/case.py
===================================================================
--- grass/trunk/lib/python/gunittest/case.py	2019-05-16 16:21:38 UTC (rev 74499)
+++ grass/trunk/lib/python/gunittest/case.py	2019-05-16 16:32:21 UTC (rev 74500)
@@ -19,7 +19,7 @@
 
 from grass.pygrass.modules import Module
 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 .checkers import (check_text_ellipsis,
@@ -1149,8 +1149,8 @@
             module.run()
             self.grass_modules.append(module.name)
         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: stderr?
             stdmsg = ('Running <{m.name}> module ended'
@@ -1162,8 +1162,8 @@
                           errors=module.outputs.stderr
                       ))
             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
         # TODO: always or only if the calling test method failed?
         # in any case, this must be done before self.fail()
@@ -1183,11 +1183,11 @@
             module.run()
             self.grass_modules.append(module.name)
         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:
-            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'
                       ' when expecting module to fail' % module.get_python())
             self.fail(self._formatMessage(msg, stdmsg))



More information about the grass-commit mailing list