8000 gh-132285: Add a test when `__annotations__` is deleted · python/cpython@43185fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 43185fb

Browse files
committed
gh-132285: Add a test when __annotations__ is deleted
1 parent 0e4cf9c commit 43185fb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Lib/test/test_annotationlib.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,24 @@ def f(x: int):
809809
{"x": "int"},
810810
)
811811

812+
def test_del_annotations(self):
813+
# gh-132285
814+
called = False
815+
class A:
816+
def __annotate__(format):
817+
nonlocal called
818+
called = True
819+
return {'a': int}
820+
821+
self.assertEqual(A.__annotations__, {'a': int})
822+
self.assertTrue(called)
823+
824+
del A.__annotations__
825+
called = False
826+
827+
self.assertEqual(A.__annotations__, {'a': int})
828+
self.assertTrue(called)
829+
812830
def test_non_dict_annotations(self):
813831
class WeirdAnnotations:
814832
@property

0 commit comments

Comments
 (0)
0