Skip to content

Commit 866aef1

Browse files
committed
Move self-tests to class level
1 parent 32a3bef commit 866aef1

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

Lib/test/test_annotationlib.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,29 +1872,27 @@ def one(_) -> C1:
18721872
one_f = ForwardRef("C", owner=one)
18731873
one_f_ga1 = get_annotations(one, format=Format.FORWARDREF)["return"]
18741874
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__)
18751877

18761878
def two(_) -> C1 | C2:
18771879
"""Two cells."""
18781880

18791881
two_f_ga1 = get_annotations(two, format=Format.FORWARDREF)["return"]
18801882
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)
18811886

18821887
type C1 = None
18831888
type C2 = None
18841889

18851890
self.assertNotEqual(A.one_f, A.one_f_ga1)
18861891
self.assertNotEqual(hash(A.one_f), hash(A.one_f_ga1))
18871892

1888-
self.assertIsInstance(A.one_f_ga1.__cell__, types.CellType)
1889-
self.assertIs(A.one_f_ga1.__cell__, A.one_f_ga2.__cell__)
1890-
18911893
self.assertEqual(A.one_f_ga1, A.one_f_ga2)
18921894
self.assertEqual(hash(A.one_f_ga1), hash(A.one_f_ga2))
18931895

1894-
self.assertIsNot(A.two_f_ga1.__cell__, A.two_f_ga2.__cell__)
1895-
self.assertIsInstance(A.two_f_ga1.__cell__, dict)
1896-
self.assertIsInstance(A.two_f_ga2.__cell__, dict)
1897-
18981896
self.assertEqual(A.two_f_ga1, A.two_f_ga2)
18991897
self.assertEqual(hash(A.two_f_ga1), hash(A.two_f_ga2))
19001898

0 commit comments

Comments
 (0)