summaryrefslogtreecommitdiff
path: root/tests/file_storage
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2018-07-10 03:26:19 -0700
committerCarlton Gibson <carlton.gibson@noumenal.es>2018-07-10 12:26:19 +0200
commite7d7d47b93d23c8a17ab297d68ec23fa2c543955 (patch)
tree9d5474e38fe47e293c44cb5caede7a6a6d834bd5 /tests/file_storage
parent338f741c5eb6b91118f6a6b7c34b5e9b47a5661d (diff)
downloaddjango-e7d7d47b93d23c8a17ab297d68ec23fa2c543955.tar.gz
Fixed ResourceWarning from unclosed test files.
When running Django tests with Python warnings enabled.
Diffstat (limited to 'tests/file_storage')
-rw-r--r--tests/file_storage/tests.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index 3a21ca9046..6253036679 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -595,12 +595,14 @@ class OverwritingStorageTests(FileStorageTests):
self.assertEqual(stored_name_1, name)
self.assertTrue(self.storage.exists(name))
self.assertTrue(os.path.exists(os.path.join(self.temp_dir, name)))
- self.assertEqual(self.storage.open(name).read(), content_1)
+ with self.storage.open(name) as fp:
+ self.assertEqual(fp.read(), content_1)
stored_name_2 = self.storage.save(name, f_2)
self.assertEqual(stored_name_2, name)
self.assertTrue(self.storage.exists(name))
self.assertTrue(os.path.exists(os.path.join(self.temp_dir, name)))
- self.assertEqual(self.storage.open(name).read(), content_2)
+ with self.storage.open(name) as fp:
+ self.assertEqual(fp.read(), content_2)
finally:
self.storage.delete(name)