MCPcopy Index your code
hub / github.com/python/cpython / test_future_annotations

Method test_future_annotations

Lib/test/test_typing.py:8248–8258  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

8246 self.assertEqual(Z.__annotate__(annotationlib.Format.STRING), {"a": "None", "b": "str"})
8247
8248 def test_future_annotations(self):
8249 code = """
8250 from __future__ import annotations
8251 from typing import NamedTuple
8252 class X(NamedTuple):
8253 a: int
8254 b: None
8255 """
8256 ns = run_code(textwrap.dedent(code))
8257 X = ns['X']
8258 self.assertEqual(X.__annotations__, {'a': EqualToForwardRef("int"), 'b': EqualToForwardRef("None")})
8259
8260 def test_deferred_annotations(self):
8261 class X(NamedTuple):

Callers

nothing calls this directly

Calls 4

run_codeFunction · 0.90
EqualToForwardRefClass · 0.90
dedentMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected