MCPcopy Index your code
hub / github.com/RustPython/RustPython / A

Class A

Lib/test/test_annotationlib.py:1868–1885  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1866 def test_forward_equality_and_hash_with_cells(self):
1867 """Regression test for GH-143831."""
1868 class A:
1869 def one(_) -> C1:
1870 """One cell."""
1871
1872 one_f = ForwardRef("C1", owner=one)
1873 one_f_ga1 = get_annotations(one, format=Format.FORWARDREF)["return"]
1874 one_f_ga2 = get_annotations(one, format=Format.FORWARDREF)["return"]
1875 self.assertIsInstance(one_f_ga1.__cell__, types.CellType)
1876 self.assertIs(one_f_ga1.__cell__, one_f_ga2.__cell__)
1877
1878 def two(_) -> C1 | C2:
1879 """Two cells."""
1880
1881 two_f_ga1 = get_annotations(two, format=Format.FORWARDREF)["return"]
1882 two_f_ga2 = get_annotations(two, format=Format.FORWARDREF)["return"]
1883 self.assertIsNot(two_f_ga1.__cell__, two_f_ga2.__cell__)
1884 self.assertIsInstance(two_f_ga1.__cell__, dict)
1885 self.assertIsInstance(two_f_ga2.__cell__, dict)
1886
1887 type C1 = None
1888 type C2 = None

Callers

nothing calls this directly

Calls 5

ForwardRefClass · 0.90
get_annotationsFunction · 0.90
assertIsInstanceMethod · 0.80
assertIsNotMethod · 0.80
assertIsMethod · 0.45

Tested by

no test coverage detected