Skip to content

Commit 434efcd

Browse files
committed
fix: Clean up tests
1 parent af7ca87 commit 434efcd

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

tests/test_unit_tests.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def setUp(self):
3636

3737
def test_stream_read(self):
3838
with open(self.testPath, "rb") as file:
39-
reader = Reader("image/jpeg",file)
40-
json = reader.json()
41-
self.assertIn("C.jpg", json)
39+
reader = Reader("image/jpeg", file)
40+
json_data = reader.json()
41+
self.assertIn("C.jpg", json_data)
4242

4343
def test_stream_read_and_parse(self):
4444
with open(self.testPath, "rb") as file:
@@ -49,7 +49,7 @@ def test_stream_read_and_parse(self):
4949

5050
def test_json_decode_err(self):
5151
with self.assertRaises(Error.Io):
52-
manifest_store = Reader("image/jpeg","foo")
52+
manifest_store = Reader("image/jpeg", "foo")
5353

5454
def test_reader_bad_format(self):
5555
with self.assertRaises(Error.NotSupported):
@@ -59,16 +59,18 @@ def test_reader_bad_format(self):
5959
def test_settings_trust(self):
6060
#load_settings_file("tests/fixtures/settings.toml")
6161
with open(self.testPath, "rb") as file:
62-
reader = Reader("image/jpeg",file)
63-
json = reader.json()
64-
self.assertIn("C.jpg", json)
62+
reader = Reader("image/jpeg", file)
63+
json_data = reader.json()
64+
self.assertIn("C.jpg", json_data)
6565

6666
class TestBuilder(unittest.TestCase):
6767
def setUp(self):
6868
# Use the fixtures_dir fixture to set up paths
6969
self.data_dir = os.path.join(os.path.dirname(__file__), "fixtures")
70-
self.certs = open(os.path.join(self.data_dir, "es256_certs.pem"), "rb").read()
71-
self.key = open(os.path.join(self.data_dir, "es256_private.key"), "rb").read()
70+
with open(os.path.join(self.data_dir, "es256_certs.pem"), "rb") as cert_file:
71+
self.certs = cert_file.read()
72+
with open(os.path.join(self.data_dir, "es256_private.key"), "rb") as key_file:
73+
self.key = key_file.read()
7274

7375
# Create a local Ps256 signer with certs and a timestamp server
7476
self.signer_info = C2paSignerInfo(
@@ -118,6 +120,7 @@ def test_streams_sign(self):
118120
json_data = reader.json()
119121
self.assertIn("Python Test", json_data)
120122
self.assertNotIn("validation_status", json_data)
123+
output.close()
121124

122125
def test_archive_sign(self):
123126
with open(self.testPath, "rb") as file:
@@ -132,6 +135,8 @@ def test_archive_sign(self):
132135
json_data = reader.json()
133136
self.assertIn("Python Test", json_data)
134137
self.assertNotIn("validation_status", json_data)
138+
archive.close()
139+
output.close()
135140

136141
def test_remote_sign(self):
137142
with open(self.testPath, "rb") as file:
@@ -144,6 +149,7 @@ def test_remote_sign(self):
144149
json_data = reader.json()
145150
self.assertIn("Python Test", json_data)
146151
self.assertNotIn("validation_status", json_data)
152+
output.close()
147153

148154
if __name__ == '__main__':
149155
unittest.main()

0 commit comments

Comments
 (0)