diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-06-10 04:01:23 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-06-10 04:01:23 (GMT) |
commit | 602d8db2bc5ddc9a2de2843df92db53365478b3d (patch) | |
tree | e799948843586f96ec1e0d4058135cf49a0b1c7c /Lib/test/test_xrange.py | |
parent | 1f2f61a78f80933a3e703df1ab08f14e70ea87d5 (diff) | |
download | cpython-602d8db2bc5ddc9a2de2843df92db53365478b3d.zip cpython-602d8db2bc5ddc9a2de2843df92db53365478b3d.tar.gz cpython-602d8db2bc5ddc9a2de2843df92db53365478b3d.tar.bz2 |
Added better pickling support to xrange objects.
Cleaned up the unit test.
Diffstat (limited to 'Lib/test/test_xrange.py')
-rw-r--r-- | Lib/test/test_xrange.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/test/test_xrange.py b/Lib/test/test_xrange.py index ab68c36..7a2eea5 100644 --- a/Lib/test/test_xrange.py +++ b/Lib/test/test_xrange.py @@ -2,6 +2,7 @@ import test.test_support, unittest import sys +import pickle import warnings warnings.filterwarnings("ignore", "integer argument expected", @@ -57,15 +58,15 @@ class XrangeTest(unittest.TestCase): self.assertEqual(len(r), sys.maxint) self.assertRaises(OverflowError, xrange, -sys.maxint-1, sys.maxint, 2) - def test_getnewargs(self): - def test(*args): - r = xrange(*args) - return list(r) == list(xrange(*r.__getnewargs__())) - tests = [(13,), (0, 11), (-22, 10), (20, 3, -1), - (13, 21, 3), (-2, 2, 2)] - for t in tests: - self.assert_(test(*t), - "xrange.__getnewargs__() failed with %r" % (t,)) + def test_pickling(self): + testcases = [(13,), (0, 11), (-22, 10), (20, 3, -1), + (13, 21, 3), (-2, 2, 2)] + for proto in range(pickle.HIGHEST_PROTOCOL): + for t in testcases: + r = xrange(*t) + self.assertEquals(list(pickle.loads(pickle.dumps(r, proto))), + list(r)) + def test_main(): test.test_support.run_unittest(XrangeTest) |