Back to index

python3.2  3.2.2
Public Member Functions
test.test_sort.TestBugs Class Reference

List of all members.

Public Member Functions

def test_bug453523
def test_undetected_mutation

Detailed Description

Definition at line 134 of file test_sort.py.


Member Function Documentation

Definition at line 136 of file test_sort.py.

00136 
00137     def test_bug453523(self):
00138         # bug 453523 -- list.sort() crasher.
00139         # If this fails, the most likely outcome is a core dump.
00140         # Mutations during a list sort should raise a ValueError.
00141 
00142         class C:
00143             def __lt__(self, other):
00144                 if L and random.random() < 0.75:
00145                     L.pop()
00146                 else:
00147                     L.append(3)
00148                 return random.random() < 0.5
00149 
00150         L = [C() for i in range(50)]
00151         self.assertRaises(ValueError, L.sort)

Here is the call graph for this function:

Definition at line 152 of file test_sort.py.

00152 
00153     def test_undetected_mutation(self):
00154         # Python 2.4a1 did not always detect mutation
00155         memorywaster = []
00156         for i in range(20):
00157             def mutating_cmp(x, y):
00158                 L.append(3)
00159                 L.pop()
00160                 return (x > y) - (x < y)
00161             L = [1,2]
00162             self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
00163             def mutating_cmp(x, y):
00164                 L.append(3)
00165                 del L[:]
00166                 return (x > y) - (x < y)
00167             self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
00168             memorywaster = [memorywaster]
00169 
00170 #==============================================================================

Here is the call graph for this function:


The documentation for this class was generated from the following file: