@@ -78,9 +78,18 @@ def dummymodule(method: str):
7878def deferredannos (method : str ):
7979 if sys .version_info < (3 , 14 ):
8080 raise pytest .skip ("Deferred annotations are only supported in Python 3.14+" )
81+
8182 return _fixture_module ("deferredannos" , method )
8283
8384
85+ @pytest .fixture (scope = "module" )
86+ def pep695 (method : str ):
87+ if sys .version_info < (3 , 12 ):
88+ raise pytest .skip ("PEP 695 type parameter syntax requires Python 3.12+" )
89+
90+ return _fixture_module ("pep695" , method )
91+
92+
8493def test_type_checked_func (dummymodule ):
8594 assert dummymodule .type_checked_func (2 , 3 ) == 6
8695
@@ -386,3 +395,25 @@ def test_failure(self, deferredannos):
386395 match = r'argument "x" \(int\) is not an instance of deferredannos.NotYetDefined' ,
387396 ):
388397 deferredannos .uses_forwardref (1 )
398+
399+
400+ class TestParametrized :
401+ def test_success_func (self , pep695 ):
402+ assert pep695 .parametrized_func (1 , "2" ) == 1
403+
404+ def test_success_method (self , pep695 ):
405+ assert pep695 .ParametrizedClass [int ]().method (1 , "2" ) == 1
406+
407+ def test_failure_func (self , pep695 ):
408+ with pytest .raises (
409+ TypeCheckError ,
410+ match = r'argument "y" \(int\) is not an instance of str' ,
411+ ):
412+ pep695 .parametrized_func (1 , 2 )
413+
414+ def test_failure_method (self , pep695 ):
415+ with pytest .raises (
416+ TypeCheckError ,
417+ match = r'argument "y" \(int\) is not an instance of str' ,
418+ ):
419+ pep695 .ParametrizedClass [int ]().method ("str" , 2 )
0 commit comments