Opened 6 years ago
Last modified 6 years ago
#3783 closed defect
Python 3: ./raster/r.patch/testsuite/test_rpatch_artificial.py is broken — at Initial Version
Reported by: | pmav99 | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Tests | Version: | svn-trunk |
Keywords: | Cc: | ||
CPU: | Unspecified | Platform: | Unspecified |
Description
This is the traceback:
====================================================================== ERROR: test_patching_cell (__main__.TestSmallDataNoOverlap) Test patching two neighboring CELL raster maps ---------------------------------------------------------------------- Traceback (most recent call last): File "raster/r.patch/testsuite/test_rpatch_artificial.py", line 162, in test_patching_cell self.cell_patched_ref, precision=0) File "etc/python/grass/gunittest/case.py", line 767, in assertRastersNoDifference 'assertRastersNoDifference') File "etc/python/grass/gunittest/case.py", line 681, in _compute_difference_raster s=second)) File "etc/python/grass/gunittest/gmodules.py", line 128, in call_module output, errors = process.communicate(input=stdin) File "/usr/lib/python3.7/subprocess.py", line 939, in communicate stdout, stderr = self._communicate(input, endtime, timeout) File "/usr/lib/python3.7/subprocess.py", line 1666, in _communicate input_view = memoryview(self._input) TypeError: memoryview: a bytes-like object is required, not 'str'
This is the the suggested fix (git diff):
diff --git a/lib/python/gunittest/case.py b/lib/python/gunittest/case.py index cf995e4b2..d94a72b69 100644 --- a/lib/python/gunittest/case.py +++ b/lib/python/gunittest/case.py @@ -675,10 +675,12 @@ class TestCase(unittest.TestCase): """ diff = self._get_unique_name('compute_difference_raster_' + name_part + '_' + first + '_minus_' + second) - call_module('r.mapcalc', - stdin='"{d}" = "{f}" - "{s}"'.format(d=diff, - f=first, - s=second)) + expression = '"{d}" = "{f}" - "{s}"'.format( + d=diff, + f=first, + s=second + ) + call_module('r.mapcalc', stdin=expression.encode("utf-8")) return diff # TODO: name of map generation is repeted three times
Works on both Python 2 and Python 3
Note:
See TracTickets
for help on using tickets.