@@ -900,10 +900,12 @@ async def coro(self):
900900
901901class DeprecatedCoroTests (BaseTestCase ):
902902 def test_asyncio_iscoroutinefunction (self ):
903- self .assertFalse (asyncio .coroutines .iscoroutinefunction (func ))
904- self .assertFalse (asyncio .coroutines .iscoroutinefunction (Cls .func ))
905- self .assertTrue (asyncio .coroutines .iscoroutinefunction (coro ))
906- self .assertTrue (asyncio .coroutines .iscoroutinefunction (Cls .coro ))
903+ with warnings .catch_warnings ():
904+ warnings .simplefilter ("ignore" , DeprecationWarning )
905+ self .assertFalse (asyncio .coroutines .iscoroutinefunction (func ))
906+ self .assertFalse (asyncio .coroutines .iscoroutinefunction (Cls .func ))
907+ self .assertTrue (asyncio .coroutines .iscoroutinefunction (coro ))
908+ self .assertTrue (asyncio .coroutines .iscoroutinefunction (Cls .coro ))
907909
908910 @skipUnless (TYPING_3_12_ONLY or TYPING_3_13_0_RC , "inspect.iscoroutinefunction works differently on Python < 3.12" )
909911 def test_inspect_iscoroutinefunction (self ):
@@ -7282,7 +7284,7 @@ def test_cannot_instantiate_vars(self):
72827284
72837285 def test_bound_errors (self ):
72847286 with self .assertRaises (TypeError ):
7285- TypeVar ('X' , bound = Union )
7287+ TypeVar ('X' , bound = Optional )
72867288 with self .assertRaises (TypeError ):
72877289 TypeVar ('X' , str , float , bound = Employee )
72887290 with self .assertRaisesRegex (TypeError ,
@@ -8262,19 +8264,26 @@ def f2(a: "undefined"): # noqa: F821
82628264 get_annotations (f2 , format = Format .FORWARDREF ),
82638265 {"a" : "undefined" },
82648266 )
8265- self .assertEqual (get_annotations (f2 , format = 2 ), {"a" : "undefined" })
8267+ # Test that the raw int also works
8268+ self .assertEqual (
8269+ get_annotations (f2 , format = Format .FORWARDREF .value ),
8270+ {"a" : "undefined" },
8271+ )
82668272
82678273 self .assertEqual (
82688274 get_annotations (f1 , format = Format .STRING ),
82698275 {"a" : "int" },
82708276 )
8271- self .assertEqual (get_annotations (f1 , format = 3 ), {"a" : "int" })
8277+ self .assertEqual (
8278+ get_annotations (f1 , format = Format .STRING .value ),
8279+ {"a" : "int" },
8280+ )
82728281
82738282 with self .assertRaises (ValueError ):
82748283 get_annotations (f1 , format = 0 )
82758284
82768285 with self .assertRaises (ValueError ):
8277- get_annotations (f1 , format = 4 )
8286+ get_annotations (f1 , format = 42 )
82788287
82798288 def test_custom_object_with_annotations (self ):
82808289 class C :
@@ -8313,10 +8322,17 @@ def foo(a: int, b: str):
83138322 foo .__annotations__ = {"a" : "foo" , "b" : "str" }
83148323 for format in Format :
83158324 with self .subTest (format = format ):
8316- self .assertEqual (
8317- get_annotations (foo , format = format ),
8318- {"a" : "foo" , "b" : "str" },
8319- )
8325+ if format is Format .VALUE_WITH_FAKE_GLOBALS :
8326+ with self .assertRaisesRegex (
8327+ ValueError ,
8328+ "The VALUE_WITH_FAKE_GLOBALS format is for internal use only"
8329+ ):
8330+ get_annotations (foo , format = format )
8331+ else :
8332+ self .assertEqual (
8333+ get_annotations (foo , format = format ),
8334+ {"a" : "foo" , "b" : "str" },
8335+ )
83208336
83218337 self .assertEqual (
83228338 get_annotations (foo , eval_str = True , locals = locals ()),
0 commit comments