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

Method check_tuple_from_pair

Lib/test/test_capi/test_tuple.py:124–147  ·  view source on GitHub ↗
(self, from_pair)

Source from the content-addressed store, hash-verified

122 # CRASHES pack(2, [1])
123
124 def check_tuple_from_pair(self, from_pair):
125 self.assertEqual(type(from_pair(1, 2)), tuple)
126 self.assertEqual(from_pair(1, 145325), (1, 145325))
127 self.assertEqual(from_pair(None, None), (None, None))
128 self.assertEqual(from_pair(True, False), (True, False))
129
130 # user class supports gc
131 class Temp:
132 pass
133 temp = Temp()
134 temp_rc = getrefcount(temp)
135 self.assertEqual(from_pair(temp, temp), (temp, temp))
136 self.assertEqual(getrefcount(temp), temp_rc)
137
138 self._not_tracked(from_pair(1, 2))
139 self._not_tracked(from_pair(None, None))
140 self._not_tracked(from_pair(True, False))
141 self._tracked(from_pair(temp, (1, 2)))
142 self._tracked(from_pair(temp, 1))
143 self._tracked(from_pair([], {}))
144
145 self.assertRaises(TypeError, from_pair, 1, 2, 3)
146 self.assertRaises(TypeError, from_pair, 1)
147 self.assertRaises(TypeError, from_pair)
148
149 def test_tuple_from_pair(self):
150 # Test _PyTuple_FromPair()

Callers 2

test_tuple_from_pairMethod · 0.95

Calls 5

_not_trackedMethod · 0.95
_trackedMethod · 0.95
TempClass · 0.70
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected