File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919from jwkest .jwk import RSAKey
2020from jwkest .jwk import base64_to_long
2121import os .path
22+ import pytest
2223
2324__author__ = 'rohe0002'
2425BASEDIR = os .path .abspath (os .path .dirname (__file__ ))
@@ -54,14 +55,12 @@ def test_urlsafe_base64decode():
5455 s0 = base64 .b64encode (data )
5556 # try to convert it back to long, should throw an exception if the strict
5657 # function is used
57- try :
58- l = base64url_to_long (s0 )
59- except ValueError :
60- pass
61- else :
62- assert False
63- # Not else
58+ with pytest .raises (ValueError ):
59+ base64url_to_long (s0 )
60+
61+ # Not else, should not raise exception
6462 l = base64_to_long (s0 )
63+ assert l
6564
6665
6766def test_pem_cert2rsa ():
@@ -238,25 +237,15 @@ def test_cmp_rsa_ec():
238237
239238 _key2 = ECKey (** ECKEY )
240239
241- try :
242- assert _key1 == _key2
243- except AssertionError :
244- pass
245- else :
246- assert False
240+ assert _key1 != _key2
247241
248242
249243def test_cmp_neq_ec ():
250244 priv , pub = P256 .key_pair ()
251245 _key1 = ECKey (x = pub [0 ], y = pub [1 ], d = priv , crv = "P-256" )
252246 _key2 = ECKey (** ECKEY )
253247
254- try :
255- assert _key1 == _key2
256- except AssertionError :
257- pass
258- else :
259- assert False
248+ assert _key1 != _key2
260249
261250
262251JWKS = {"keys" : [
You can’t perform that action at this time.
0 commit comments