New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 fixes - fix dirutil, fileutil, and xml_parser tests #6229

Merged
merged 4 commits into from Jul 26, 2018

Conversation

Projects
None yet
2 participants
@Eric-Arellano
Copy link
Contributor

Eric-Arellano commented Jul 24, 2018

Problem

Dirutil tests failing due to unicode vs bytes.

dirutil.py itself is fine. I decided safe_file_dump() and read_file() should still work with bytes, not unicode.

Related PRs

To get completely green on Py3, requires #6226 and #6228. This can be merged before them both, though, as it shouldn't break Py2 and we aren't running Py3 yet.

@@ -149,7 +149,7 @@ class Dir(datatype(['path'])):
class File(datatype(['path', 'contents'])):
@classmethod
def empty(cls, path):
return cls(path, contents=b'')
return cls(path, contents='')

This comment has been minimized.

@Eric-Arellano

Eric-Arellano Jul 24, 2018

Contributor

Throughout the tests for comparing trees, contents was being encoded as byte strings in the expected output. I'm not sure why - the tests pass when unicode in Py2, and the bytes present an issue when using Py3.

@@ -396,7 +396,7 @@ def test_rm_rf_no_such_file_not_an_error(self, file_name='./vanishing_file'):
def test_readwrite_file(self):
with temporary_dir() as td:
test_filename = os.path.join(td, 'test.out')
test_content = '3333'
test_content = b'3333'

This comment has been minimized.

@Eric-Arellano

Eric-Arellano Jul 24, 2018

Contributor

Must be bytes for safe_file_dump() and read_file() to work.

@Eric-Arellano Eric-Arellano changed the title Fix dirutil tests to pass in Py3 Python 3 fixes - fix dirutil and fileutil tests Jul 24, 2018

@Eric-Arellano Eric-Arellano changed the title Python 3 fixes - fix dirutil and fileutil tests Python 3 fixes - fix dirutil, fileutil, and xml_parser tests Jul 25, 2018

@stuhood stuhood merged commit f6c526c into pantsbuild:master Jul 26, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:py3-fixes_dirutil-tests branch Jul 26, 2018

CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018

Python 3 fixes - fix dirutil, fileutil, and xml_parser tests (pantsbu…
…ild#6229)

### Problem
Dirutil tests failing due to unicode vs bytes. 

`dirutil.py` itself is fine. I decided `safe_file_dump()` and `read_file()` should still work with bytes, not unicode.

### Related PRs
To get completely green on Py3, requires pantsbuild#6226 and pantsbuild#6228. This can be merged before them both, though, as it shouldn't break Py2 and we aren't running Py3 yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment