Bug 1471622 - Fix mozfile's test_tempfile.py under Python 3.5; r?davehunt
MozReview-Commit-ID: JuWRTVEFJtv
--- a/testing/mozbase/mozfile/tests/manifest.ini
+++ b/testing/mozbase/mozfile/tests/manifest.ini
@@ -2,11 +2,10 @@
subsuite = mozbase, os == "linux"
[test_extract.py]
[test_load.py]
skip-if = python == 3
[test_move_remove.py]
skip-if = python == 3
[test_tempdir.py]
[test_tempfile.py]
-skip-if = python == 3
[test_tree.py]
[test_url.py]
--- a/testing/mozbase/mozfile/tests/test_tempfile.py
+++ b/testing/mozbase/mozfile/tests/test_tempfile.py
@@ -30,31 +30,31 @@ class TestNamedTemporaryFile(unittest.Te
test_string = b"A simple test"
with mozfile.NamedTemporaryFile() as temp:
# Test we can write to file
temp.write(test_string)
# Forced flush, so that we can read later
temp.flush()
# Test we can open the file again on all platforms
- self.assertEqual(open(temp.name).read(), test_string)
+ self.assertEqual(open(temp.name, 'rb').read(), test_string)
def test_iteration(self):
"""ensure the line iterator works"""
# make a file and write to it
tf = mozfile.NamedTemporaryFile()
- notes = ['doe', 'rae', 'mi']
+ notes = [b'doe', b'rae', b'mi']
for note in notes:
tf.write(b'%s\n' % note)
tf.flush()
# now read from it
tf.seek(0)
- lines = [line.rstrip('\n') for line in tf.readlines()]
+ lines = [line.rstrip(b'\n') for line in tf.readlines()]
self.assertEqual(lines, notes)
# now read from it iteratively
lines = []
for line in tf:
lines.append(line.strip())
self.assertEqual(lines, []) # because we did not seek(0)
tf.seek(0)