Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_deque Namespace Reference

Classes

class  BadCmp
class  MutateCmp
class  TestBasic
class  TestVariousIteratorArgs
class  Deque
class  DequeWithBadIter
class  TestSubclass
class  SubclassWithKwargs
class  TestSubclassWithKwargs

Functions

def fail
def test_deepcopy
 def test_pickle_recursive(self): d = deque('abc') d.append(d) for i in range(pickle.HIGHEST_PROTOCOL + 1): e = pickle.loads(pickle.dumps(d, i)) self.assertNotEqual(id(d), id(e)) self.assertEqual(id(e), id(e[-1]))
def test_copy
def test_reversed
def test_gc_doesnt_blowup
def test_container_iterator
def test_weakref
 def test_pickle(self): d = Deque('abc') d.append(d)
def test_strange_subclass
def test_main

Variables

int BIG = 100000
string libreftest
dictionary __test__ = {'libreftest' : libreftest}

Function Documentation

Definition at line 13 of file test_deque.py.

00013 
00014 def fail():
00015     raise SyntaxError
00016     yield 1

Definition at line 505 of file test_deque.py.

00505 
00506     def test_container_iterator(self):
00507         # Bug #3680: tp_traverse was not implemented for deque iterator objects
00508         class C(object):
00509             pass
00510         for i in range(2):
00511             obj = C()
00512             ref = weakref.ref(obj)
00513             if i == 0:
00514                 container = deque([obj, 1])
00515             else:
00516                 container = reversed(deque([obj, 1]))
00517             obj.x = iter(container)
00518             del obj, container
00519             gc.collect()
00520             self.assertTrue(ref() is None, "Cycle was not collected")

def test.test_deque.test_copy (   self)

Definition at line 483 of file test_deque.py.

00483 
00484     def test_copy(self):
00485         mut = [10]
00486         d = deque([mut])
00487         e = copy.copy(d)
00488         self.assertEqual(list(d), list(e))
00489         mut[0] = 11
00490         self.assertNotEqual(id(d), id(e))
00491         self.assertEqual(list(d), list(e))

Here is the call graph for this function:

def test_pickle_recursive(self): d = deque('abc') d.append(d) for i in range(pickle.HIGHEST_PROTOCOL + 1): e = pickle.loads(pickle.dumps(d, i)) self.assertNotEqual(id(d), id(e)) self.assertEqual(id(e), id(e[-1]))

Definition at line 474 of file test_deque.py.

00474 
00475     def test_deepcopy(self):
00476         mut = [10]
00477         d = deque([mut])
00478         e = copy.deepcopy(d)
00479         self.assertEqual(list(d), list(e))
00480         mut[0] = 11
00481         self.assertNotEqual(id(d), id(e))
00482         self.assertNotEqual(list(d), list(e))

Here is the call graph for this function:

Definition at line 496 of file test_deque.py.

00496 
00497     def test_gc_doesnt_blowup(self):
00498         import gc
00499         # This used to assert-fail in deque_traverse() under a debug
00500         # build, or run wild with a NULL pointer in a release build.
00501         d = deque()
00502         for i in range(100):
00503             d.append(1)
00504             gc.collect()

def test.test_deque.test_main (   verbose = None)

Definition at line 762 of file test_deque.py.

00762 
00763 def test_main(verbose=None):
00764     import sys
00765     test_classes = (
00766         TestBasic,
00767         TestVariousIteratorArgs,
00768         TestSubclass,
00769         TestSubclassWithKwargs,
00770     )
00771 
00772     support.run_unittest(*test_classes)
00773 
00774     # verify reference counting
00775     if verbose and hasattr(sys, "gettotalrefcount"):
00776         import gc
00777         counts = [None] * 5
00778         for i in range(len(counts)):
00779             support.run_unittest(*test_classes)
00780             gc.collect()
00781             counts[i] = sys.gettotalrefcount()
00782         print(counts)
00783 
00784     # doctests
00785     from test import test_deque
00786     support.run_doctest(test_deque, verbose)

Definition at line 492 of file test_deque.py.

00492 
00493     def test_reversed(self):
00494         for s in ('abcd', range(2000)):
00495             self.assertEqual(list(reversed(deque(s))), list(reversed(s)))

Definition at line 636 of file test_deque.py.

00636 
00637     def test_strange_subclass(self):
00638         class X(deque):
00639             def __iter__(self):
00640                 return iter([])
00641         d1 = X([1,2,3])
00642         d2 = X([4,5,6])
00643         d1 == d2   # not clear if this is supposed to be True or False,
00644                    # but it used to give a SystemError
00645 

def test_pickle(self): d = Deque('abc') d.append(d)

e = pickle.loads(pickle.dumps(d)) self.assertNotEqual(id(d), id(e)) self.assertEqual(type(d), type(e)) dd = d.pop() ee = e.pop() self.assertEqual(id(e), id(ee)) self.assertEqual(d, e)

d.x = d e = pickle.loads(pickle.dumps(d)) self.assertEqual(id(e), id(e.x))

d = DequeWithBadIter('abc') self.assertRaises(TypeError, pickle.dumps, d)

Definition at line 629 of file test_deque.py.

00629 
00630     def test_weakref(self):
00631         d = deque('gallahad')
00632         p = weakref.proxy(d)
00633         self.assertEqual(str(p), str(d))
00634         d = None
00635         self.assertRaises(ReferenceError, str, p)


Variable Documentation

Definition at line 760 of file test_deque.py.

Definition at line 11 of file test_deque.py.

Definition at line 657 of file test_deque.py.