diff options
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 1dec09ca4..d1b377e76 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", @@ -1888,7 +1888,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) @@ -1906,7 +1907,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) @@ -1923,7 +1925,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) @@ -1940,7 +1943,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) |