Back to index

python3.2  3.2.2
Public Member Functions
test.test_bigmem.ListTest Class Reference

List of all members.

Public Member Functions

def test_compare
def basic_test_concat
def test_concat_small
def test_concat_large
def basic_test_inplace_concat
def test_inplace_concat_small
def test_inplace_concat_large
def test_contains
def test_hash
def test_index_and_slice
def basic_test_repeat
def test_repeat_small
def test_repeat_large
def basic_test_inplace_repeat
def test_inplace_repeat_small
def test_inplace_repeat_large
def basic_test_repr
def test_repr_small
def test_repr_large
def test_append
def test_count
def basic_test_extend
def test_extend_small
def test_extend_large
def test_index
def test_insert
def test_pop
def test_remove
def test_reverse
def test_sort

Detailed Description

Definition at line 871 of file test_bigmem.py.


Member Function Documentation

def test.test_bigmem.ListTest.basic_test_concat (   self,
  size 
)

Definition at line 895 of file test_bigmem.py.

00895 
00896     def basic_test_concat(self, size):
00897         l = [[]] * size
00898         self.assertEqual(len(l), size)
00899         l = l + l
00900         self.assertEqual(len(l), size * 2)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_bigmem.ListTest.basic_test_extend (   self,
  size 
)

Definition at line 1062 of file test_bigmem.py.

01062 
01063     def basic_test_extend(self, size):
01064         l = [object] * size
01065         l.extend(l)
01066         self.assertEqual(len(l), size * 2)
01067         self.assertTrue(l[0] is l[-1])
01068         self.assertTrue(l[size - 1] is l[size + 1])

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 909 of file test_bigmem.py.

00909 
00910     def basic_test_inplace_concat(self, size):
00911         l = [sys.stdout] * size
00912         l += l
00913         self.assertEqual(len(l), size * 2)
00914         self.assertTrue(l[0] is l[-1])
00915         self.assertTrue(l[size - 1] is l[size + 1])

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1009 of file test_bigmem.py.

01009 
01010     def basic_test_inplace_repeat(self, size):
01011         l = ['']
01012         l *= size
01013         self.assertEqual(len(l), size)
01014         self.assertTrue(l[0] is l[-1])
01015         del l
01016 
01017         l = [''] * size
01018         l *= 2
01019         self.assertEqual(len(l), size * 2)
01020         self.assertTrue(l[size - 1] is l[-1])

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_bigmem.ListTest.basic_test_repeat (   self,
  size 
)

Definition at line 993 of file test_bigmem.py.

00993 
00994     def basic_test_repeat(self, size):
00995         l = [] * size
00996         self.assertFalse(l)
00997         l = [''] * size
00998         self.assertEqual(len(l), size)
00999         l = l * 2
01000         self.assertEqual(len(l), size * 2)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_bigmem.ListTest.basic_test_repr (   self,
  size 
)

Definition at line 1029 of file test_bigmem.py.

01029 
01030     def basic_test_repr(self, size):
01031         l = [0] * size
01032         s = repr(l)
01033         # The repr of a list of 0's is exactly three times the list length.
01034         self.assertEqual(len(s), size * 3)
01035         self.assertEqual(s[:5], '[0, 0')
01036         self.assertEqual(s[-5:], '0, 0]')
01037         self.assertEqual(s.count('0'), size)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_bigmem.ListTest.test_append (   self,
  size 
)

Definition at line 1049 of file test_bigmem.py.

01049 
01050     def test_append(self, size):
01051         l = [object()] * size
01052         l.append(object())
01053         self.assertEqual(len(l), size+1)
01054         self.assertTrue(l[-3] is l[-2])
01055         self.assertFalse(l[-2] is l[-1])

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_compare (   self,
  size 
)

Definition at line 879 of file test_bigmem.py.

00879 
00880     def test_compare(self, size):
00881         l1 = [''] * size
00882         l2 = [''] * size
00883         self.assertEqual(l1, l2)
00884         del l2
00885         l2 = [''] * (size + 1)
00886         self.assertFalse(l1 == l2)
00887         del l2
00888         l2 = [2] * size
00889         self.assertFalse(l1 == l2)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_concat_large (   self,
  size 
)

Definition at line 906 of file test_bigmem.py.

00906 
00907     def test_concat_large(self, size):
00908         return self.basic_test_concat(size)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_concat_small (   self,
  size 
)

Definition at line 902 of file test_bigmem.py.

00902 
00903     def test_concat_small(self, size):
00904         return self.basic_test_concat(size)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_contains (   self,
  size 
)

Definition at line 925 of file test_bigmem.py.

00925 
00926     def test_contains(self, size):
00927         l = [1, 2, 3, 4, 5] * size
00928         self.assertEqual(len(l), size * 5)
00929         self.assertIn(5, l)
00930         self.assertNotIn([1, 2, 3, 4, 5], l)
00931         self.assertNotIn(0, l)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_count (   self,
  size 
)

Definition at line 1057 of file test_bigmem.py.

01057 
01058     def test_count(self, size):
01059         l = [1, 2, 3, 4, 5] * size
01060         self.assertEqual(l.count(1), size)
01061         self.assertEqual(l.count("1"), 0)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_extend_large (   self,
  size 
)

Definition at line 1074 of file test_bigmem.py.

01074 
01075     def test_extend_large(self, size):
01076         return self.basic_test_extend(size)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_extend_small (   self,
  size 
)

Definition at line 1070 of file test_bigmem.py.

01070 
01071     def test_extend_small(self, size):
01072         return self.basic_test_extend(size)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_hash (   self,
  size 
)

Definition at line 933 of file test_bigmem.py.

00933 
00934     def test_hash(self, size):
00935         l = [0] * size
00936         self.assertRaises(TypeError, hash, l)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_index (   self,
  size 
)

Definition at line 1078 of file test_bigmem.py.

01078 
01079     def test_index(self, size):
01080         l = [1, 2, 3, 4, 5] * size
01081         size *= 5
01082         self.assertEqual(l.index(1), 0)
01083         self.assertEqual(l.index(5, size - 5), size - 1)
01084         self.assertEqual(l.index(5, size - 5, size), size - 1)
01085         self.assertRaises(ValueError, l.index, 1, size - 4, size)
01086         self.assertRaises(ValueError, l.index, 6)

Here is the call graph for this function:

Definition at line 938 of file test_bigmem.py.

00938 
00939     def test_index_and_slice(self, size):
00940         l = [None] * size
00941         self.assertEqual(len(l), size)
00942         self.assertEqual(l[-1], None)
00943         self.assertEqual(l[5], None)
00944         self.assertEqual(l[size - 1], None)
00945         self.assertRaises(IndexError, operator.getitem, l, size)
00946         self.assertEqual(l[:5], [None] * 5)
00947         self.assertEqual(l[-5:], [None] * 5)
00948         self.assertEqual(l[20:25], [None] * 5)
00949         self.assertEqual(l[-25:-20], [None] * 5)
00950         self.assertEqual(l[size - 5:], [None] * 5)
00951         self.assertEqual(l[size - 5:size], [None] * 5)
00952         self.assertEqual(l[size - 6:size - 2], [None] * 4)
00953         self.assertEqual(l[size:size], [])
00954         self.assertEqual(l[size:size+5], [])
00955 
00956         l[size - 2] = 5
00957         self.assertEqual(len(l), size)
00958         self.assertEqual(l[-3:], [None, 5, None])
00959         self.assertEqual(l.count(5), 1)
00960         self.assertRaises(IndexError, operator.setitem, l, size, 6)
00961         self.assertEqual(len(l), size)
00962 
00963         l[size - 7:] = [1, 2, 3, 4, 5]
00964         size -= 2
00965         self.assertEqual(len(l), size)
00966         self.assertEqual(l[-7:], [None, None, 1, 2, 3, 4, 5])
00967 
00968         l[:7] = [1, 2, 3, 4, 5]
00969         size -= 2
00970         self.assertEqual(len(l), size)
00971         self.assertEqual(l[:7], [1, 2, 3, 4, 5, None, None])
00972 
00973         del l[size - 1]
00974         size -= 1
00975         self.assertEqual(len(l), size)
00976         self.assertEqual(l[-1], 4)
00977 
00978         del l[-2:]
00979         size -= 2
00980         self.assertEqual(len(l), size)
00981         self.assertEqual(l[-1], 2)
00982 
00983         del l[0]
00984         size -= 1
00985         self.assertEqual(len(l), size)
00986         self.assertEqual(l[0], 2)
00987 
00988         del l[:2]
00989         size -= 2
00990         self.assertEqual(len(l), size)
00991         self.assertEqual(l[0], 4)

Here is the call graph for this function:

Definition at line 921 of file test_bigmem.py.

00921 
00922     def test_inplace_concat_large(self, size):
00923         return self.basic_test_inplace_concat(size)

Here is the call graph for this function:

Definition at line 917 of file test_bigmem.py.

00917 
00918     def test_inplace_concat_small(self, size):
00919         return self.basic_test_inplace_concat(size)

Here is the call graph for this function:

Definition at line 1026 of file test_bigmem.py.

01026 
01027     def test_inplace_repeat_large(self, size):
01028         return self.basic_test_inplace_repeat(size)

Here is the call graph for this function:

Definition at line 1022 of file test_bigmem.py.

01022 
01023     def test_inplace_repeat_small(self, size):
01024         return self.basic_test_inplace_repeat(size)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_insert (   self,
  size 
)

Definition at line 1089 of file test_bigmem.py.

01089 
01090     def test_insert(self, size):
01091         l = [1.0] * size
01092         l.insert(size - 1, "A")
01093         size += 1
01094         self.assertEqual(len(l), size)
01095         self.assertEqual(l[-3:], [1.0, "A", 1.0])
01096 
01097         l.insert(size + 1, "B")
01098         size += 1
01099         self.assertEqual(len(l), size)
01100         self.assertEqual(l[-3:], ["A", 1.0, "B"])
01101 
01102         l.insert(1, "C")
01103         size += 1
01104         self.assertEqual(len(l), size)
01105         self.assertEqual(l[:3], [1.0, "C", 1.0])
01106         self.assertEqual(l[size - 3:], ["A", 1.0, "B"])

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_pop (   self,
  size 
)

Definition at line 1108 of file test_bigmem.py.

01108 
01109     def test_pop(self, size):
01110         l = ["a", "b", "c", "d", "e"] * size
01111         size *= 5
01112         self.assertEqual(len(l), size)
01113 
01114         item = l.pop()
01115         size -= 1
01116         self.assertEqual(len(l), size)
01117         self.assertEqual(item, "e")
01118         self.assertEqual(l[-2:], ["c", "d"])
01119 
01120         item = l.pop(0)
01121         size -= 1
01122         self.assertEqual(len(l), size)
01123         self.assertEqual(item, "a")
01124         self.assertEqual(l[:2], ["b", "c"])
01125 
01126         item = l.pop(size - 2)
01127         size -= 1
01128         self.assertEqual(len(l), size)
01129         self.assertEqual(item, "c")
01130         self.assertEqual(l[-2:], ["b", "d"])

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_remove (   self,
  size 
)

Definition at line 1132 of file test_bigmem.py.

01132 
01133     def test_remove(self, size):
01134         l = [10] * size
01135         self.assertEqual(len(l), size)
01136 
01137         l.remove(10)
01138         size -= 1
01139         self.assertEqual(len(l), size)
01140 
01141         # Because of the earlier l.remove(), this append doesn't trigger
01142         # a resize.
01143         l.append(5)
01144         size += 1
01145         self.assertEqual(len(l), size)
01146         self.assertEqual(l[-2:], [10, 5])
01147         l.remove(5)
01148         size -= 1
01149         self.assertEqual(len(l), size)
01150         self.assertEqual(l[-2:], [10, 10])

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_repeat_large (   self,
  size 
)

Definition at line 1006 of file test_bigmem.py.

01006 
01007     def test_repeat_large(self, size):
01008         return self.basic_test_repeat(size)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_repeat_small (   self,
  size 
)

Definition at line 1002 of file test_bigmem.py.

01002 
01003     def test_repeat_small(self, size):
01004         return self.basic_test_repeat(size)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_repr_large (   self,
  size 
)

Definition at line 1043 of file test_bigmem.py.

01043 
01044     def test_repr_large(self, size):
01045         return self.basic_test_repr(size)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_repr_small (   self,
  size 
)

Definition at line 1039 of file test_bigmem.py.

01039 
01040     def test_repr_small(self, size):
01041         return self.basic_test_repr(size)

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_reverse (   self,
  size 
)

Definition at line 1152 of file test_bigmem.py.

01152 
01153     def test_reverse(self, size):
01154         l = [1, 2, 3, 4, 5] * size
01155         l.reverse()
01156         self.assertEqual(len(l), size * 5)
01157         self.assertEqual(l[-5:], [5, 4, 3, 2, 1])
01158         self.assertEqual(l[:5], [5, 4, 3, 2, 1])

Here is the call graph for this function:

def test.test_bigmem.ListTest.test_sort (   self,
  size 
)

Definition at line 1160 of file test_bigmem.py.

01160 
01161     def test_sort(self, size):
01162         l = [1, 2, 3, 4, 5] * size
01163         l.sort()
01164         self.assertEqual(len(l), size * 5)
01165         self.assertEqual(l.count(1), size)
01166         self.assertEqual(l[:10], [1] * 10)
01167         self.assertEqual(l[-10:], [5] * 10)

Here is the call graph for this function:


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