Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Always close files in the file_storage tests.

  • Loading branch information...
commit dfbcbf212493b9e5bb527e7ec2d97ae3cec480fa 1 parent e0d67f3
@alex alex authored Alex Gaynor committed
Showing with 6 additions and 6 deletions.
  1. +6 −6 tests/regressiontests/file_storage/tests.py
View
12 tests/regressiontests/file_storage/tests.py
@@ -197,8 +197,8 @@ def test_file_save_with_path(self):
ContentFile(b'file saved with path'))
self.assertTrue(self.storage.exists('path/to'))
- self.assertEqual(self.storage.open('path/to/test.file').read(),
- b'file saved with path')
+ with self.storage.open('path/to/test.file') as f:
+ self.assertEqual(f.read(), b'file saved with path')
self.assertTrue(os.path.exists(
os.path.join(self.temp_dir, 'path', 'to', 'test.file')))
@@ -305,13 +305,13 @@ def fake_makedirs(path):
self.storage.save('normal/test.file',
ContentFile(b'saved normally'))
- self.assertEqual(self.storage.open('normal/test.file').read(),
- b'saved normally')
+ with self.storage.open('normal/test.file') as f:
+ self.assertEqual(f.read(), b'saved normally')
self.storage.save('raced/test.file',
ContentFile(b'saved with race'))
- self.assertEqual(self.storage.open('raced/test.file').read(),
- b'saved with race')
+ with self.storage.open('raced/test.file') as f:
+ self.assertEqual(f.read(), b'saved with race')
# Check that OSErrors aside from EEXIST are still raised.
self.assertRaises(OSError,
Please sign in to comment.
Something went wrong with that request. Please try again.