Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit13104f3

Browse files
authored
gh-107905: Test raising__value__ forTypeAliasType (#107997)
1 parent71962e5 commit13104f3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎Lib/test/test_type_aliases.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,24 @@ def test_recursive_repr(self):
168168
self.assertEqual(repr(GenericRecursive[GenericRecursive[int]]),
169169
"GenericRecursive[GenericRecursive[int]]")
170170

171+
deftest_raising(self):
172+
typeMissingName=list[_My_X]
173+
withself.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+
typeExprException=1/0
186+
withself.assertRaises(ZeroDivisionError):
187+
ExprException.__value__
188+
171189

172190
classTypeAliasConstructorTest(unittest.TestCase):
173191
deftest_basic(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp