1+ from typing import NoReturn
2+
13import pytest
24
35from a2a .client import A2AClientError , A2AClientHTTPError , A2AClientJSONError
68class TestA2AClientError :
79 """Test cases for the base A2AClientError class."""
810
9- def test_instantiation (self ):
11+ def test_instantiation (self ) -> None :
1012 """Test that A2AClientError can be instantiated."""
1113 error = A2AClientError ('Test error message' )
1214 assert isinstance (error , Exception )
1315 assert str (error ) == 'Test error message'
1416
15- def test_inheritance (self ):
17+ def test_inheritance (self ) -> None :
1618 """Test that A2AClientError inherits from Exception."""
1719 error = A2AClientError ()
1820 assert isinstance (error , Exception )
@@ -21,31 +23,31 @@ def test_inheritance(self):
2123class TestA2AClientHTTPError :
2224 """Test cases for A2AClientHTTPError class."""
2325
24- def test_instantiation (self ):
26+ def test_instantiation (self ) -> None :
2527 """Test that A2AClientHTTPError can be instantiated with status_code and message."""
2628 error = A2AClientHTTPError (404 , 'Not Found' )
2729 assert isinstance (error , A2AClientError )
2830 assert error .status_code == 404
2931 assert error .message == 'Not Found'
3032
31- def test_message_formatting (self ):
33+ def test_message_formatting (self ) -> None :
3234 """Test that the error message is formatted correctly."""
3335 error = A2AClientHTTPError (500 , 'Internal Server Error' )
3436 assert str (error ) == 'HTTP Error 500: Internal Server Error'
3537
36- def test_inheritance (self ):
38+ def test_inheritance (self ) -> None :
3739 """Test that A2AClientHTTPError inherits from A2AClientError."""
3840 error = A2AClientHTTPError (400 , 'Bad Request' )
3941 assert isinstance (error , A2AClientError )
4042
41- def test_with_empty_message (self ):
43+ def test_with_empty_message (self ) -> None :
4244 """Test behavior with an empty message."""
4345 error = A2AClientHTTPError (403 , '' )
4446 assert error .status_code == 403
4547 assert error .message == ''
4648 assert str (error ) == 'HTTP Error 403: '
4749
48- def test_with_various_status_codes (self ):
50+ def test_with_various_status_codes (self ) -> None :
4951 """Test with different HTTP status codes."""
5052 test_cases = [
5153 (200 , 'OK' ),
@@ -68,29 +70,29 @@ def test_with_various_status_codes(self):
6870class TestA2AClientJSONError :
6971 """Test cases for A2AClientJSONError class."""
7072
71- def test_instantiation (self ):
73+ def test_instantiation (self ) -> None :
7274 """Test that A2AClientJSONError can be instantiated with a message."""
7375 error = A2AClientJSONError ('Invalid JSON format' )
7476 assert isinstance (error , A2AClientError )
7577 assert error .message == 'Invalid JSON format'
7678
77- def test_message_formatting (self ):
79+ def test_message_formatting (self ) -> None :
7880 """Test that the error message is formatted correctly."""
7981 error = A2AClientJSONError ('Missing required field' )
8082 assert str (error ) == 'JSON Error: Missing required field'
8183
82- def test_inheritance (self ):
84+ def test_inheritance (self ) -> None :
8385 """Test that A2AClientJSONError inherits from A2AClientError."""
8486 error = A2AClientJSONError ('Parsing error' )
8587 assert isinstance (error , A2AClientError )
8688
87- def test_with_empty_message (self ):
89+ def test_with_empty_message (self ) -> None :
8890 """Test behavior with an empty message."""
8991 error = A2AClientJSONError ('' )
9092 assert error .message == ''
9193 assert str (error ) == 'JSON Error: '
9294
93- def test_with_various_messages (self ):
95+ def test_with_various_messages (self ) -> None :
9496 """Test with different error messages."""
9597 test_messages = [
9698 'Malformed JSON' ,
@@ -109,21 +111,21 @@ def test_with_various_messages(self):
109111class TestExceptionHierarchy :
110112 """Test the exception hierarchy and relationships."""
111113
112- def test_exception_hierarchy (self ):
114+ def test_exception_hierarchy (self ) -> None :
113115 """Test that the exception hierarchy is correct."""
114116 assert issubclass (A2AClientError , Exception )
115117 assert issubclass (A2AClientHTTPError , A2AClientError )
116118 assert issubclass (A2AClientJSONError , A2AClientError )
117119
118- def test_catch_specific_exception (self ):
120+ def test_catch_specific_exception (self ) -> None :
119121 """Test that specific exceptions can be caught."""
120122 try :
121123 raise A2AClientHTTPError (404 , 'Not Found' )
122124 except A2AClientHTTPError as e :
123125 assert e .status_code == 404
124126 assert e .message == 'Not Found'
125127
126- def test_catch_base_exception (self ):
128+ def test_catch_base_exception (self ) -> None :
127129 """Test that derived exceptions can be caught as base exception."""
128130 exceptions = [
129131 A2AClientHTTPError (404 , 'Not Found' ),
@@ -140,7 +142,7 @@ def test_catch_base_exception(self):
140142class TestExceptionRaising :
141143 """Test cases for raising and handling the exceptions."""
142144
143- def test_raising_http_error (self ):
145+ def test_raising_http_error (self ) -> NoReturn :
144146 """Test raising an HTTP error and checking its properties."""
145147 with pytest .raises (A2AClientHTTPError ) as excinfo :
146148 raise A2AClientHTTPError (429 , 'Too Many Requests' )
@@ -150,7 +152,7 @@ def test_raising_http_error(self):
150152 assert error .message == 'Too Many Requests'
151153 assert str (error ) == 'HTTP Error 429: Too Many Requests'
152154
153- def test_raising_json_error (self ):
155+ def test_raising_json_error (self ) -> NoReturn :
154156 """Test raising a JSON error and checking its properties."""
155157 with pytest .raises (A2AClientJSONError ) as excinfo :
156158 raise A2AClientJSONError ('Invalid format' )
@@ -159,7 +161,7 @@ def test_raising_json_error(self):
159161 assert error .message == 'Invalid format'
160162 assert str (error ) == 'JSON Error: Invalid format'
161163
162- def test_raising_base_error (self ):
164+ def test_raising_base_error (self ) -> NoReturn :
163165 """Test raising the base error."""
164166 with pytest .raises (A2AClientError ) as excinfo :
165167 raise A2AClientError ('Generic client error' )
@@ -178,7 +180,9 @@ def test_raising_base_error(self):
178180 (500 , 'Server Error' , 'HTTP Error 500: Server Error' ),
179181 ],
180182)
181- def test_http_error_parametrized (status_code : int , message : str , expected : str ):
183+ def test_http_error_parametrized (
184+ status_code : int , message : str , expected : str
185+ ) -> None :
182186 """Parametrized test for HTTP errors with different status codes."""
183187 error = A2AClientHTTPError (status_code , message )
184188 assert error .status_code == status_code
@@ -194,7 +198,7 @@ def test_http_error_parametrized(status_code: int, message: str, expected: str):
194198 ('Parsing failed' , 'JSON Error: Parsing failed' ),
195199 ],
196200)
197- def test_json_error_parametrized (message : str , expected : str ):
201+ def test_json_error_parametrized (message : str , expected : str ) -> None :
198202 """Parametrized test for JSON errors with different messages."""
199203 error = A2AClientJSONError (message )
200204 assert error .message == message
0 commit comments