File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -8101,6 +8101,23 @@ class T4(TypedDict, Generic[S]): pass
8101
8101
self .assertEqual (klass .__optional_keys__ , set ())
8102
8102
self .assertIsInstance (klass (), dict )
8103
8103
8104
+ def test_setname_called_on_things_in_class_namespace (self ):
8105
+ class CustomException (Exception ): pass
8106
+
8107
+ class Annoying :
8108
+ def __set_name__ (self , owner , name ):
8109
+ raise CustomException ("Cannot do that!" )
8110
+
8111
+ with self .assertRaisesRegex (CustomException , "Cannot do that!" ) as cm :
8112
+ class Foo (TypedDict ):
8113
+ attr = Annoying ()
8114
+
8115
+ expected_note = (
8116
+ "Error calling __set_name__ on 'Annoying' instance "
8117
+ "'attr' in 'Foo'"
8118
+ )
8119
+ self .assertIn (expected_note , cm .exception .__notes__ )
8120
+
8104
8121
8105
8122
class RequiredTests (BaseTestCase ):
8106
8123
You can’t perform that action at this time.
0 commit comments