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

Method test_instantiate_immutable

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

Source from the content-addressed store, hash-verified

9726 self.assertEqual(MyCount[int]([4, 4, 5]), {4: 2, 5: 1})
9727
9728 def test_instantiate_immutable(self):
9729 class C:
9730 def __setattr__(self, key, value):
9731 raise Exception("should be ignored")
9732
9733 A = Annotated[C, "a decoration"]
9734 # gh-115165: This used to cause RuntimeError to be raised
9735 # when we tried to set `__orig_class__` on the `C` instance
9736 # returned by the `A()` call
9737 self.assertIsInstance(A(), C)
9738
9739 def test_cannot_instantiate_forward(self):
9740 A = Annotated["int", (5, 6)]

Callers

nothing calls this directly

Calls 2

assertIsInstanceMethod · 0.80
AClass · 0.70

Tested by

no test coverage detected