@@ -36,13 +36,13 @@ class TestPycryptoAlgorithms:
3636 def test_rsa_should_parse_pem_public_key (self ):
3737 algo = RSAAlgorithm (RSAAlgorithm .SHA256 )
3838
39- with open (key_path ("testkey2_rsa.pub.pem" ), "r" ) as pem_key :
39+ with open (key_path ("testkey2_rsa.pub.pem" )) as pem_key :
4040 algo .prepare_key (pem_key .read ())
4141
4242 def test_rsa_should_accept_unicode_key (self ):
4343 algo = RSAAlgorithm (RSAAlgorithm .SHA256 )
4444
45- with open (key_path ("testkey_rsa" ), "r" ) as rsa_key :
45+ with open (key_path ("testkey_rsa" )) as rsa_key :
4646 algo .prepare_key (force_unicode (rsa_key .read ()))
4747
4848 def test_rsa_should_reject_non_string_key (self ):
@@ -67,10 +67,10 @@ def test_rsa_sign_should_generate_correct_signature_value(self):
6767 )
6868 )
6969
70- with open (key_path ("testkey_rsa" ), "r" ) as keyfile :
70+ with open (key_path ("testkey_rsa" )) as keyfile :
7171 jwt_key = algo .prepare_key (keyfile .read ())
7272
73- with open (key_path ("testkey_rsa.pub" ), "r" ) as keyfile :
73+ with open (key_path ("testkey_rsa.pub" )) as keyfile :
7474 jwt_pub_key = algo .prepare_key (keyfile .read ())
7575
7676 algo .sign (jwt_message , jwt_key )
@@ -95,7 +95,7 @@ def test_rsa_verify_should_return_false_if_signature_invalid(self):
9595
9696 jwt_sig += force_bytes ("123" ) # Signature is now invalid
9797
98- with open (key_path ("testkey_rsa.pub" ), "r" ) as keyfile :
98+ with open (key_path ("testkey_rsa.pub" )) as keyfile :
9999 jwt_pub_key = algo .prepare_key (keyfile .read ())
100100
101101 result = algo .verify (jwt_message , jwt_pub_key , jwt_sig )
@@ -117,7 +117,7 @@ def test_rsa_verify_should_return_true_if_signature_valid(self):
117117 )
118118 )
119119
120- with open (key_path ("testkey_rsa.pub" ), "r" ) as keyfile :
120+ with open (key_path ("testkey_rsa.pub" )) as keyfile :
121121 jwt_pub_key = algo .prepare_key (keyfile .read ())
122122
123123 result = algo .verify (jwt_message , jwt_pub_key , jwt_sig )
@@ -126,7 +126,7 @@ def test_rsa_verify_should_return_true_if_signature_valid(self):
126126 def test_rsa_prepare_key_should_be_idempotent (self ):
127127 algo = RSAAlgorithm (RSAAlgorithm .SHA256 )
128128
129- with open (key_path ("testkey_rsa.pub" ), "r" ) as keyfile :
129+ with open (key_path ("testkey_rsa.pub" )) as keyfile :
130130 jwt_pub_key_first = algo .prepare_key (keyfile .read ())
131131 jwt_pub_key_second = algo .prepare_key (jwt_pub_key_first )
132132
@@ -146,7 +146,7 @@ def test_ec_should_reject_non_string_key(self):
146146 def test_ec_should_accept_unicode_key (self ):
147147 algo = ECAlgorithm (ECAlgorithm .SHA256 )
148148
149- with open (key_path ("testkey_ec" ), "r" ) as ec_key :
149+ with open (key_path ("testkey_ec" )) as ec_key :
150150 algo .prepare_key (force_unicode (ec_key .read ()))
151151
152152 def test_ec_sign_should_generate_correct_signature_value (self ):
@@ -162,10 +162,10 @@ def test_ec_sign_should_generate_correct_signature_value(self):
162162 )
163163 )
164164
165- with open (key_path ("testkey_ec" ), "r" ) as keyfile :
165+ with open (key_path ("testkey_ec" )) as keyfile :
166166 jwt_key = algo .prepare_key (keyfile .read ())
167167
168- with open (key_path ("testkey_ec.pub" ), "r" ) as keyfile :
168+ with open (key_path ("testkey_ec.pub" )) as keyfile :
169169 jwt_pub_key = algo .prepare_key (keyfile .read ())
170170
171171 algo .sign (jwt_message , jwt_key )
@@ -187,7 +187,7 @@ def test_ec_verify_should_return_false_if_signature_invalid(self):
187187
188188 jwt_sig += force_bytes ("123" ) # Signature is now invalid
189189
190- with open (key_path ("testkey_ec.pub" ), "r" ) as keyfile :
190+ with open (key_path ("testkey_ec.pub" )) as keyfile :
191191 jwt_pub_key = algo .prepare_key (keyfile .read ())
192192
193193 result = algo .verify (jwt_message , jwt_pub_key , jwt_sig )
@@ -206,7 +206,7 @@ def test_ec_verify_should_return_true_if_signature_valid(self):
206206 )
207207 )
208208
209- with open (key_path ("testkey_ec.pub" ), "r" ) as keyfile :
209+ with open (key_path ("testkey_ec.pub" )) as keyfile :
210210 jwt_pub_key = algo .prepare_key (keyfile .read ())
211211
212212 result = algo .verify (jwt_message , jwt_pub_key , jwt_sig )
@@ -215,7 +215,7 @@ def test_ec_verify_should_return_true_if_signature_valid(self):
215215 def test_ec_prepare_key_should_be_idempotent (self ):
216216 algo = ECAlgorithm (ECAlgorithm .SHA256 )
217217
218- with open (key_path ("testkey_ec.pub" ), "r" ) as keyfile :
218+ with open (key_path ("testkey_ec.pub" )) as keyfile :
219219 jwt_pub_key_first = algo .prepare_key (keyfile .read ())
220220 jwt_pub_key_second = algo .prepare_key (jwt_pub_key_first )
221221
@@ -235,16 +235,16 @@ def test_ed25519_should_reject_non_string_key(self):
235235 with pytest .raises (TypeError ):
236236 algo .prepare_key (None )
237237
238- with open (key_path ("testkey_ed25519" ), "r" ) as keyfile :
238+ with open (key_path ("testkey_ed25519" )) as keyfile :
239239 jwt_key = algo .prepare_key (keyfile .read ())
240240
241- with open (key_path ("testkey_ed25519.pub" ), "r" ) as keyfile :
241+ with open (key_path ("testkey_ed25519.pub" )) as keyfile :
242242 jwt_pub_key = algo .prepare_key (keyfile .read ())
243243
244244 def test_ed25519_should_accept_unicode_key (self ):
245245 algo = Ed25519Algorithm ()
246246
247- with open (key_path ("testkey_ed25519" ), "r" ) as ec_key :
247+ with open (key_path ("testkey_ed25519" )) as ec_key :
248248 algo .prepare_key (force_unicode (ec_key .read ()))
249249
250250 def test_ed25519_sign_should_generate_correct_signature_value (self ):
@@ -254,10 +254,10 @@ def test_ed25519_sign_should_generate_correct_signature_value(self):
254254
255255 expected_sig = base64 .b64decode (force_bytes (self .hello_world_sig ))
256256
257- with open (key_path ("testkey_ed25519" ), "r" ) as keyfile :
257+ with open (key_path ("testkey_ed25519" )) as keyfile :
258258 jwt_key = algo .prepare_key (keyfile .read ())
259259
260- with open (key_path ("testkey_ed25519.pub" ), "r" ) as keyfile :
260+ with open (key_path ("testkey_ed25519.pub" )) as keyfile :
261261 jwt_pub_key = algo .prepare_key (keyfile .read ())
262262
263263 algo .sign (jwt_message , jwt_key )
@@ -272,7 +272,7 @@ def test_ed25519_verify_should_return_false_if_signature_invalid(self):
272272
273273 jwt_sig += force_bytes ("123" ) # Signature is now invalid
274274
275- with open (key_path ("testkey_ed25519.pub" ), "r" ) as keyfile :
275+ with open (key_path ("testkey_ed25519.pub" )) as keyfile :
276276 jwt_pub_key = algo .prepare_key (keyfile .read ())
277277
278278 result = algo .verify (jwt_message , jwt_pub_key , jwt_sig )
@@ -284,7 +284,7 @@ def test_ed25519_verify_should_return_true_if_signature_valid(self):
284284 jwt_message = self .hello_world
285285 jwt_sig = base64 .b64decode (force_bytes (self .hello_world_sig ))
286286
287- with open (key_path ("testkey_ed25519.pub" ), "r" ) as keyfile :
287+ with open (key_path ("testkey_ed25519.pub" )) as keyfile :
288288 jwt_pub_key = algo .prepare_key (keyfile .read ())
289289
290290 result = algo .verify (jwt_message , jwt_pub_key , jwt_sig )
@@ -293,7 +293,7 @@ def test_ed25519_verify_should_return_true_if_signature_valid(self):
293293 def test_ed25519_prepare_key_should_be_idempotent (self ):
294294 algo = Ed25519Algorithm ()
295295
296- with open (key_path ("testkey_ed25519.pub" ), "r" ) as keyfile :
296+ with open (key_path ("testkey_ed25519.pub" )) as keyfile :
297297 jwt_pub_key_first = algo .prepare_key (keyfile .read ())
298298 jwt_pub_key_second = algo .prepare_key (jwt_pub_key_first )
299299
0 commit comments