mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
gh-124206: Fix calling get_annotate_function() on static types (#124208)
Fixes #124206. No news entry because the bug this fixes was never released.
This commit is contained in:
parent
3b6bfa77aa
commit
96f619faa7
3 changed files with 45 additions and 1 deletions
|
@ -928,6 +928,27 @@ class MetaclassTests(unittest.TestCase):
|
|||
self.assertIs(annotate_func, None)
|
||||
|
||||
|
||||
class TestGetAnnotateFunction(unittest.TestCase):
|
||||
def test_static_class(self):
|
||||
self.assertIsNone(get_annotate_function(object))
|
||||
self.assertIsNone(get_annotate_function(int))
|
||||
|
||||
def test_unannotated_class(self):
|
||||
class C:
|
||||
pass
|
||||
|
||||
self.assertIsNone(get_annotate_function(C))
|
||||
|
||||
D = type("D", (), {})
|
||||
self.assertIsNone(get_annotate_function(D))
|
||||
|
||||
def test_annotated_class(self):
|
||||
class C:
|
||||
a: int
|
||||
|
||||
self.assertEqual(get_annotate_function(C)(Format.VALUE), {"a": int})
|
||||
|
||||
|
||||
class TestAnnotationLib(unittest.TestCase):
|
||||
def test__all__(self):
|
||||
support.check__all__(self, annotationlib)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue