зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1471622 - Fix mozfile's test_tempfile.py under Python 3.5; r=davehunt
MozReview-Commit-ID: JuWRTVEFJtv --HG-- extra : rebase_source : 11393471d8d199623d2150071fa75e1e5a26504f
This commit is contained in:
Родитель
79eaf1fafd
Коммит
bb8e7208ea
|
@ -7,6 +7,5 @@ skip-if = python == 3
|
|||
skip-if = python == 3
|
||||
[test_tempdir.py]
|
||||
[test_tempfile.py]
|
||||
skip-if = python == 3
|
||||
[test_tree.py]
|
||||
[test_url.py]
|
||||
|
|
|
@ -35,21 +35,21 @@ class TestNamedTemporaryFile(unittest.TestCase):
|
|||
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
|
||||
|
|
Загрузка…
Ссылка в новой задаче