File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,24 @@ def test_recursive_repr(self):
168
168
self .assertEqual (repr (GenericRecursive [GenericRecursive [int ]]),
169
169
"GenericRecursive[GenericRecursive[int]]" )
170
170
171
+ def test_raising (self ):
172
+ type MissingName = list [_My_X ]
173
+ with self .assertRaisesRegex (
174
+ NameError ,
175
+ "cannot access free variable '_My_X' where it is not associated with a value" ,
176
+ ):
177
+ MissingName .__value__
178
+ _My_X = int
179
+ self .assertEqual (MissingName .__value__ , list [int ])
180
+ del _My_X
181
+ # Cache should still work:
182
+ self .assertEqual (MissingName .__value__ , list [int ])
183
+
184
+ # Explicit exception:
185
+ type ExprException = 1 / 0
186
+ with self .assertRaises (ZeroDivisionError ):
187
+ ExprException .__value__
188
+
171
189
172
190
class TypeAliasConstructorTest (unittest .TestCase ):
173
191
def test_basic (self ):
You can’t perform that action at this time.
0 commit comments