Bug 1471622 - Fix mozfile's test_tempfile.py under Python 3.5; r?davehunt draft
authorRaphael Pierzina <rpierzina@mozilla.com>
Tue, 03 Jul 2018 10:09:41 +0200
changeset 813515 bc7f65d86fe392b821f197c45e2f62176e5125b0
parent 813514 753166d9697fef498b8f84b5c4b41fdcb84241d3
push id114923
push userbmo:rpierzina@mozilla.com
push dateTue, 03 Jul 2018 10:02:36 +0000
reviewersdavehunt
bugs1471622
milestone63.0a1
Bug 1471622 - Fix mozfile's test_tempfile.py under Python 3.5; r?davehunt MozReview-Commit-ID: JuWRTVEFJtv
testing/mozbase/mozfile/tests/manifest.ini
testing/mozbase/mozfile/tests/test_tempfile.py
--- 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)