diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-08-20 15:42:38 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2025-10-24 18:32:21 +0200 |
| commit | 1fb4e99abe52f98d34339f12940582f2ca51ecb8 (patch) | |
| tree | 8d30e88c649be96dcc19e05d27b77895c2ada899 /archaeological_context_records/tests.py | |
| parent | b98b3004bb1a47674c9595a5d674dc4ba83344c8 (diff) | |
| download | Ishtar-1fb4e99abe52f98d34339f12940582f2ca51ecb8.tar.bz2 Ishtar-1fb4e99abe52f98d34339f12940582f2ca51ecb8.zip | |
🐛 fix unclosed file
Diffstat (limited to 'archaeological_context_records/tests.py')
| -rw-r--r-- | archaeological_context_records/tests.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py index 79dd502ac..852cd3aa7 100644 --- a/archaeological_context_records/tests.py +++ b/archaeological_context_records/tests.py @@ -87,10 +87,10 @@ class ImportContextRecordTest(ImportTest, TestCase): filename = root + "importer-GIS-UE.zip" self.restore_serialized(filename) imp_type = ImporterType.objects.get(name="GIS - UE") - imp_file = open(root + data_name, "rb") - file_dict = { - "imported_file": SimpleUploadedFile(imp_file.name, imp_file.read()) - } + with open(root + data_name, "rb") as imp_file: + file_dict = { + "imported_file": SimpleUploadedFile(imp_file.name, imp_file.read()) + } post_dict = { "importer_type": imp_type.pk, "name": "cr_geo_import", @@ -1889,7 +1889,8 @@ class GraphGenerationTest(ContextRecordInit, TestCase): self.assertIsNotNone(cr_2.relation_image) self.assertIsNotNone(cr_2.relation_bitmap_image) self.assertIsNotNone(cr_2.relation_dot) - content = open(cr_2.relation_dot.path).read() + with open(cr_2.relation_dot.path) as f: + content = f.read() self.assertIn('"CR 1"', content) self.assertIn('"CR 1B"', content) self.assertIn('"CR 2B"', content) @@ -1907,7 +1908,8 @@ class GraphGenerationTest(ContextRecordInit, TestCase): self.assertIsNotNone(operation.relation_image) self.assertIsNotNone(operation.relation_bitmap_image) self.assertIsNotNone(operation.relation_dot) - content = open(operation.relation_dot.path).read() + with open(operation.relation_dot.path) as f: + content = f.read() self.assertIn('"CR 1"', content) self.assertIn('"CR 1B"', content) self.assertIn('"CR 2B"', content) @@ -1924,7 +1926,8 @@ class GraphGenerationTest(ContextRecordInit, TestCase): self.assertIsNotNone(cr_2.relation_image_above) self.assertIsNotNone(cr_2.relation_bitmap_image_above) self.assertIsNotNone(cr_2.relation_dot_above) - content = open(cr_2.relation_dot_above.path).read() + with open(cr_2.relation_dot_above.path) as f: + content = f.read() self.assertNotIn('"CR 1"', content) self.assertNotIn('"CR 1B"', content) self.assertIn('"CR 2B"', content) @@ -1941,7 +1944,8 @@ class GraphGenerationTest(ContextRecordInit, TestCase): self.assertIsNotNone(cr_2.relation_image_below) self.assertIsNotNone(cr_2.relation_bitmap_image_below) self.assertIsNotNone(cr_2.relation_dot_below) - content = open(cr_2.relation_dot_below.path).read() + with open(cr_2.relation_dot_below.path) as f: + content = f.read() self.assertIn('"CR 1"', content) self.assertIn('"CR 1B"', content) self.assertIn('"CR 2B"', content) |
