[GRASS-dev] [GRASS GIS] #3782: Python 3: raster/r.in.poly/testsuite/test_rinpoly.py is broken

#3782: Python 3: raster/r.in.poly/testsuite/test_rinpoly.py is broken
-------------------------+-------------------------
Reporter: pmav99 | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Tests | Version: svn-trunk
Keywords: | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
This is the error:
{{{

ERROR: testLabels (__main__.TestRInPoly)
Test type of resulting map
----------------------------------------------------------------------
Traceback (most recent call last):
   File "raster/r.in.poly/testsuite/test_rinpoly.py", line 103, in
testLabels
     self.tmpFile.write(input1)
   File "/usr/lib/python3.7/tempfile.py", line 481, in func_wrapper
     return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'
}}}

The problems is that NamedTemporaryFiles are opened in binary mode by
default:
-
https://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile
-
https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile

This is the git diff for the fix:
{{{
diff --git a/raster/r.in.poly/testsuite/test_rinpoly.py
b/raster/r.in.poly/testsuite/test_rinpoly.py
index 243dcf9c9..60933bf0c 100644
--- a/raster/r.in.poly/testsuite/test_rinpoly.py
+++ b/raster/r.in.poly/testsuite/test_rinpoly.py
@@ -6,7 +6,7 @@ from grass.script.core import read_command

  input1 = \
-"""
+b"""
  A
  634308.630394 223320.356473
  640640.712946 223092.401501
}}}

Should work as it is in Python2 too.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3782&gt;
GRASS GIS <https://grass.osgeo.org>

#3782: Python 3: raster/r.in.poly/testsuite/test_rinpoly.py is broken
--------------------------+-------------------------
  Reporter: pmav99 | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone:
Component: Tests | Version: svn-trunk
Resolution: fixed | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by neteler):

* status: new => closed
* resolution: => fixed

Comment:

In [changeset:"74309" 74309]:
{{{
#!CommitTicketReference repository="" revision="74309"
testsuite: Python3 fix for test_rinpoly.py (fixes #3782) (contributed by
pmav99)
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3782#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>