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

Method test_undetected_mutation

Lib/test/test_sort.py:172–187  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

170 self.assertRaises(ValueError, L.sort)
171
172 def test_undetected_mutation(self):
173 # Python 2.4a1 did not always detect mutation
174 memorywaster = []
175 for i in range(20):
176 def mutating_cmp(x, y):
177 L.append(3)
178 L.pop()
179 return (x > y) - (x < y)
180 L = [1,2]
181 self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
182 def mutating_cmp(x, y):
183 L.append(3)
184 del L[:]
185 return (x > y) - (x < y)
186 self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
187 memorywaster = [memorywaster]
188
189#==============================================================================
190

Callers

nothing calls this directly

Calls 2

cmp_to_keyFunction · 0.90
assertRaisesMethod · 0.45

Tested by

no test coverage detected