@@ -638,7 +638,7 @@ class C "void *" ""
638
638
C.__init__ = C.meth
639
639
[clinic start generated code]*/
640
640
"""
641
- err = "'__init__' must be a normal method, not a classmethod, staticmethod or getter !"
641
+ err = "'__init__' must be a normal method; got 'FunctionKind.CLASS_METHOD' !"
642
642
self .expect_failure (block , err , lineno = 8 )
643
643
644
644
def test_validate_cloned_new (self ):
@@ -2180,17 +2180,22 @@ class Foo "" ""
2180
2180
self .expect_failure (block , err , lineno = 2 )
2181
2181
2182
2182
def test_init_must_be_a_normal_method (self ):
2183
- err = "'__init__' must be a normal method, not a classmethod, staticmethod or getter!"
2184
- annotations = ["@classmethod" , "@staticmethod" , "@getter" ]
2185
- for annotation in annotations :
2186
- with self .subTest (annotation = annotation ):
2183
+ err_template = "'__init__' must be a normal method; got 'FunctionKind.{}'!"
2184
+ annotations = {
2185
+ "@classmethod" : "CLASS_METHOD" ,
2186
+ "@staticmethod" : "STATIC_METHOD" ,
2187
+ "@getter" : "GETTER" ,
2188
+ }
2189
+ for annotation , invalid_kind in annotations .items ():
2190
+ with self .subTest (annotation = annotation , invalid_kind = invalid_kind ):
2187
2191
block = f"""
2188
2192
module foo
2189
2193
class Foo "" ""
2190
2194
{ annotation }
2191
2195
Foo.__init__
2192
2196
"""
2193
- self .expect_failure (block , err , lineno = 3 )
2197
+ expected_error = err_template .format (invalid_kind )
2198
+ self .expect_failure (block , expected_error , lineno = 3 )
2194
2199
2195
2200
def test_duplicate_coexist (self ):
2196
2201
err = "Called @coexist twice"
0 commit comments