Skip to content

Commit da28faa

Browse files
committed
gh-152315: Cover metaclass descriptors
1 parent 2792370 commit da28faa

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lib/test/test_call.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,14 @@ def register_pack(dog_type):
940940
def track_pack(cls, scent):
941941
pass
942942

943+
@classmethod
944+
def classify_pack(dog_type):
945+
pass
946+
947+
@staticmethod
948+
def tag_pack(label):
949+
pass
950+
943951
class Poodle(metaclass=DogMeta):
944952
pass
945953

@@ -1042,6 +1050,18 @@ def test_metaclass_method_too_many_args_does_not_suggest_missing_self(self):
10421050
with self.check_raises_type_error(msg):
10431051
Poodle.track_pack("trail", "river")
10441052

1053+
def test_metaclass_classmethod_does_not_suggest_missing_self(self):
1054+
"""A classmethod on a metaclass should not suggest instance self."""
1055+
msg = "DogMeta.classify_pack() takes 1 positional argument but 2 were given"
1056+
with self.check_raises_type_error(msg):
1057+
Poodle.classify_pack("standard")
1058+
1059+
def test_metaclass_staticmethod_does_not_suggest_missing_self(self):
1060+
"""A staticmethod on a metaclass should not suggest instance self."""
1061+
msg = "DogMeta.tag_pack() takes 1 positional argument but 2 were given"
1062+
with self.check_raises_type_error(msg):
1063+
Poodle.tag_pack("show", "working")
1064+
10451065
@cpython_only
10461066
class TestErrorMessagesSuggestions(unittest.TestCase):
10471067
@contextlib.contextmanager

0 commit comments

Comments
 (0)