Merge "Python 3: Fix tests using temporary text files"

This commit is contained in:
Jenkins
2014-03-28 10:14:26 +00:00
committed by Gerrit Code Review

View File

@@ -133,7 +133,7 @@ class TestLengthWrapper(testtools.TestCase):
self.assertEqual('a' * 42, read_data) self.assertEqual('a' * 42, read_data)
def test_tempfile(self): def test_tempfile(self):
with tempfile.NamedTemporaryFile() as f: with tempfile.NamedTemporaryFile(mode='w') as f:
f.write('a' * 100) f.write('a' * 100)
f.flush() f.flush()
contents = open(f.name) contents = open(f.name)
@@ -144,7 +144,7 @@ class TestLengthWrapper(testtools.TestCase):
self.assertEqual('a' * 42, read_data) self.assertEqual('a' * 42, read_data)
def test_segmented_file(self): def test_segmented_file(self):
with tempfile.NamedTemporaryFile() as f: with tempfile.NamedTemporaryFile(mode='w') as f:
segment_length = 1024 segment_length = 1024
segments = ('a', 'b', 'c', 'd') segments = ('a', 'b', 'c', 'd')
for c in segments: for c in segments: