8000 add test · python/cpython@0058b82 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0058b82

Browse files
committed
add test
1 parent 6b563db commit 0058b82

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Lib/test/test_type_annotations.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,20 @@ def test_future_annotations(self):
391391
392392
def f(x: int) -> int: pass
393393
"""
394-
ns = run_code(textwrap.dedent(code))
394+
ns = run_code(code)
395395
f = ns["f"]
396396
self.assertIsInstance(f.__annotate__, types.FunctionType)
397397
annos = {"x": "int", "return": "int"}
398398
self.assertEqual(f.__annotate__(inspect.VALUE), annos)
399399
self.assertEqual(f.__annotations__, annos)
400+
401+
def test_name_clash_with_format(self):
402+
# this test would fail if __annotate__'s parameter was called "format"
403+
code = """
404+
class format: pass
405+
406+
def f(x: format): pass
407+
"""
408+
ns = run_code(code)
409+
f = ns["f"]
410+
self.assertEqual(f.__annotations__, {"x": ns["format"]})

0 commit comments

Comments
 (0)
0