diff options
Diffstat (limited to 'archaeological_context_records')
-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) |