Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b046b76

Browse files
committed
Added test cases to detect regression on SourceForge bug #121965.
1 parent 0b796fa commit b046b76

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lib/test/test_b2.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,20 @@ def f2():
254254
if tuple(xrange(5,10)) <> tuple(range(5,10)): raise TestFailed, 'xrange(5,10)'
255255
if tuple(xrange(0,10,2)) <> tuple(range(0,10,2)):
256256
raise TestFailed, 'xrange(0,10,2)'
257+
# regression tests for SourceForge bug #121695
258+
def _range_test(r):
259+
assert r.start != r.stop, 'Test not valid for passed-in xrange object.'
260+
if r.stop in r:
261+
raise TestFailed, 'r.stop in ' + `r`
262+
if r.stop-r.step not in r:
263+
raise TestFailed, 'r.stop-r.step not in ' + `r`
264+
if r.start not in r:
265+
raise TestFailed, 'r.start not in ' + `r`
266+
if r.stop+r.step in r:
267+
raise TestFailed, 'r.stop+r.step in ' + `r`
268+
_range_test(xrange(10))
269+
_range_test(xrange(9, -1, -1))
270+
_range_test(xrange(0, 10, 2))
257271

258272
print 'zip'
259273
a = (1, 2, 3)

0 commit comments

Comments
 (0)