diff options
author | Fred Drake <fdrake@acm.org> | 2002-05-02 16:07:44 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-05-02 16:07:44 (GMT) |
commit | e0e890a4da559895149250786a6bba3e7498304e (patch) | |
tree | 205f159ccec08d9c287851c0d0b2a20e3d317adf /Lib | |
parent | edb51bb7e81191890ba267ecf39903d408a64bb0 (diff) | |
download | cpython-e0e890a4da559895149250786a6bba3e7498304e.zip cpython-e0e890a4da559895149250786a6bba3e7498304e.tar.gz cpython-e0e890a4da559895149250786a6bba3e7498304e.tar.bz2 |
Added regression tests for xrange object attributes.
See SF bug #551285.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_b2.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_b2.py b/Lib/test/test_b2.py index b930380..9f020de 100644 --- a/Lib/test/test_b2.py +++ b/Lib/test/test_b2.py @@ -289,10 +289,33 @@ def f2(): f2() print 'xrange' +import warnings +warnings.filterwarnings('ignore', r".*xrange", DeprecationWarning) if tuple(xrange(10)) != tuple(range(10)): raise TestFailed, 'xrange(10)' if tuple(xrange(5,10)) != tuple(range(5,10)): raise TestFailed, 'xrange(5,10)' if tuple(xrange(0,10,2)) != tuple(range(0,10,2)): raise TestFailed, 'xrange(0,10,2)' +r = xrange(10) +if r.tolist() != range(10): raise TestFailed, 'xrange(10).tolist()' +if r.start != 0: raise TestFailed, 'xrange(10).start' +if r.stop != 10: raise TestFailed, 'xrange(10).stop' +if r.step != 1: raise TestFailed, 'xrange(10).step' +r = xrange(3, 10) +if r.tolist() != range(3, 10): raise TestFailed, 'xrange(3, 10).tolist()' +if r.start != 3: raise TestFailed, 'xrange(3, 10).start' +if r.stop != 10: raise TestFailed, 'xrange(3, 10).stop' +if r.step != 1: raise TestFailed, 'xrange(3, 10).step' +r = xrange(3, 10, 2) +if r.tolist() != range(3, 10, 2): raise TestFailed, 'xrange(3, 10, 2).tolist()' +if r.start != 3: raise TestFailed, 'xrange(3, 10, 2).start' +if r.stop != 11: raise TestFailed, 'xrange(3, 10, 2).stop' +if r.step != 2: raise TestFailed, 'xrange(3, 10, 2).step' +r = xrange(10, 3, -1) +if r.tolist() != range(10, 3, -1): + raise TestFailed, 'xrange(10, 3, -1).tolist()' +if r.start != 10: raise TestFailed, 'xrange(10, 3, -1).start' +if r.stop != 3: raise TestFailed, 'xrange(10, 3, -1).stop' +if r.step != -1: raise TestFailed, 'xrange(10, 3, -1).step' print 'zip' a = (1, 2, 3) |