Skip to content

Commit

Permalink
BUG: py3: testUtils: Fix opening of baselineFile
Browse files Browse the repository at this point in the history
This commit fixes the following error reported when running the tests
using python3:

  File "/home/jcfr/Projects/pyradiomics/tests/testUtils.py", line 184, in readBaselineFiles
    headers = six.next(csvReader)
  _csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
  • Loading branch information
jcfr committed Feb 14, 2017
1 parent 76fb4ee commit a1c2cc6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/testUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def readBaselineFiles(self):
cls = baselineFile[9:-4]
self._logger.debug('Reading baseline for class %s', cls)
self._baseline[cls] = {}
with open(os.path.join(self._baselineDir, baselineFile), 'rb') as baselineReader:
with open(os.path.join(self._baselineDir, baselineFile), 'r' if six.PY3 else 'rb') as baselineReader:
csvReader = csv.reader(baselineReader)
headers = six.next(csvReader)
for testRow in csvReader:
Expand Down

0 comments on commit a1c2cc6

Please sign in to comment.