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

Method test_special_attrs

Lib/test/test_annotationlib.py:2022–2034  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2020 self.assertEqual(X1, X2)
2021
2022 def test_special_attrs(self):
2023 # Forward refs provide a different introspection API. __name__ and
2024 # __qualname__ make little sense for forward refs as they can store
2025 # complex typing expressions.
2026 fr = ForwardRef("set[Any]")
2027 self.assertNotHasAttr(fr, "__name__")
2028 self.assertNotHasAttr(fr, "__qualname__")
2029 self.assertEqual(fr.__module__, "annotationlib")
2030 # Forward refs are currently unpicklable once they contain a code object.
2031 fr.__forward_code__ # fill the cache
2032 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
2033 with self.assertRaises(TypeError):
2034 pickle.dumps(fr, proto)
2035
2036 def test_evaluate_string_format(self):
2037 fr = ForwardRef("set[Any]")

Callers

nothing calls this directly

Calls 5

ForwardRefClass · 0.90
assertNotHasAttrMethod · 0.80
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
dumpsMethod · 0.45

Tested by

no test coverage detected