Opened 6 years ago

Closed 6 years ago

#3782 closed defect (fixed)

Python 3: raster/r.in.poly/testsuite/test_rinpoly.py is broken

Reported by: pmav99 Owned by: grass-dev@…
Priority: normal Milestone:
Component: Tests Version: svn-trunk
Keywords: Cc:
CPU: Unspecified Platform: Unspecified

Description

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:

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.

Change History (1)

comment:1 by neteler, 6 years ago

Resolution: fixed
Status: newclosed

In 74309:

testsuite: Python3 fix for test_rinpoly.py (fixes #3782) (contributed by pmav99)

Note: See TracTickets for help on using tickets.