~pythonregexp2.7/python/issue2636-09-01+10

« back to all changes in this revision

Viewing changes to Lib/test/test_cpickle.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 21:39:45 UTC
  • mfrom: (39055.1.33 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922213945-23717m5eiqpamcyn
Merged in changes from the Single-Loop Engine branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import cPickle
 
1
import cPickle, unittest
2
2
from cStringIO import StringIO
3
3
from test.pickletester import AbstractPickleTests, AbstractPickleModuleTests
4
4
from test import test_support
90
90
        b = self.loads(self.dumps(a))
91
91
        self.assertEqual(a, b)
92
92
 
 
93
class Node(object):
 
94
    pass
 
95
 
 
96
class cPickleDeepRecursive(unittest.TestCase):
 
97
    def test_issue2702(self):
 
98
        # This should raise a RecursionLimit but in some
 
99
        # platforms (FreeBSD, win32) sometimes raises KeyError instead,
 
100
        # or just silently terminates the interpreter (=crashes).
 
101
        nodes = [Node() for i in range(500)]
 
102
        for n in nodes:
 
103
            n.connections = list(nodes)
 
104
            n.connections.remove(n)
 
105
        self.assertRaises(RuntimeError, cPickle.dumps, n)
 
106
 
 
107
    def test_issue3179(self):
 
108
        # Safe test, because I broke this case when fixing the
 
109
        # behaviour for the previous test.
 
110
        res=[]
 
111
        for x in range(1,2000):
 
112
            res.append(dict(doc=x, similar=[]))
 
113
        cPickle.dumps(res)
 
114
 
 
115
 
93
116
def test_main():
94
117
    test_support.run_unittest(
95
118
        cPickleTests,
96
119
        cPicklePicklerTests,
97
120
        cPickleListPicklerTests,
98
 
        cPickleFastPicklerTests
 
121
        cPickleFastPicklerTests,
 
122
        cPickleDeepRecursive,
99
123
    )
100
124
 
101
125
if __name__ == "__main__":