@@ -124,9 +124,8 @@ def test_invalid_claims_raise_error(
124124 key_loader = self ._key_loader (public_jwk ),
125125 )
126126
127- # Assert on the cause type and error message content
128- assert isinstance (excinfo .value .cause , expected_error_type )
129- assert expected_error_text in str (excinfo .value .cause )
127+ assert isinstance (excinfo .value .__cause__ , expected_error_type )
128+ assert expected_error_text in str (excinfo .value .__cause__ )
130129
131130 def test_invalid_signature_raises_error (self ):
132131 kid = "k1"
@@ -147,9 +146,8 @@ def test_invalid_signature_raises_error(self):
147146 key_loader = self ._key_loader (public_jwk_1 ),
148147 )
149148
150- # Invalid signature should raise a JoseError
151- assert isinstance (excinfo .value .cause , JoseError )
152- assert "signature" in str (excinfo .value .cause ).lower ()
149+ assert isinstance (excinfo .value .__cause__ , JoseError )
150+ assert "signature" in str (excinfo .value .__cause__ )
153151
154152 def test_expired_token_raises_error (self ):
155153 kid = "k1"
@@ -173,10 +171,8 @@ def test_expired_token_raises_error(self):
173171 client_id = client_id ,
174172 key_loader = self ._key_loader (public_jwk ),
175173 )
176-
177- # Expired token should raise an ExpiredTokenError
178- assert isinstance (excinfo .value .cause , ExpiredTokenError )
179- assert "expired" in str (excinfo .value .cause ).lower ()
174+ assert isinstance (excinfo .value .__cause__ , ExpiredTokenError )
175+ assert "expired" in str (excinfo .value .__cause__ )
180176
181177 def test_missing_iat_raises_error (self ):
182178 kid = "k1"
@@ -197,6 +193,5 @@ def test_missing_iat_raises_error(self):
197193 key_loader = self ._key_loader (public_jwk ),
198194 )
199195
200- # Missing iat should raise a MissingClaimError
201- assert isinstance (excinfo .value .cause , MissingClaimError )
202- assert "iat" in str (excinfo .value .cause ).lower ()
196+ assert isinstance (excinfo .value .__cause__ , MissingClaimError )
197+ assert "iat" in str (excinfo .value .__cause__ )
0 commit comments