Skip to content
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

Eric-Arellano
Copy link
Contributor

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='')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@Eric-Arellano Eric-Arellano deleted the py3-fixes_dirutil-tests branch July 26, 2018 11:16
CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018
…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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants