Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_iterlen.TestList Class Reference

------- Types that can mutate during iteration ------- More...

Inheritance diagram for test.test_iterlen.TestList:
Inheritance graph
[legend]
Collaboration diagram for test.test_iterlen.TestList:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def test_mutation
def test_invariant

Public Attributes

 it

Detailed Description

------- Types that can mutate during iteration -------

Definition at line 160 of file test_iterlen.py.


Member Function Documentation

Definition at line 162 of file test_iterlen.py.

00162 
00163     def setUp(self):
00164         self.it = iter(range(n))

Here is the caller graph for this function:

Definition at line 65 of file test_iterlen.py.

00065 
00066     def test_invariant(self):
00067         it = self.it
00068         for i in reversed(range(1, n+1)):
00069             self.assertEqual(len(it), i)
00070             next(it)
00071         self.assertEqual(len(it), 0)
00072         self.assertRaises(StopIteration, next, it)
00073         self.assertEqual(len(it), 0)

Here is the call graph for this function:

Definition at line 165 of file test_iterlen.py.

00165 
00166     def test_mutation(self):
00167         d = list(range(n))
00168         it = iter(d)
00169         next(it)
00170         next(it)
00171         self.assertEqual(len(it), n-2)
00172         d.append(n)
00173         self.assertEqual(len(it), n-1)  # grow with append
00174         d[1:] = []
00175         self.assertEqual(len(it), 0)
00176         self.assertEqual(list(it), [])
00177         d.extend(range(20))
00178         self.assertEqual(len(it), 0)

Here is the call graph for this function:


Member Data Documentation

Definition at line 163 of file test_iterlen.py.


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