]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add a regression test that was removed prematurely. This tests deprecated
authorFred Drake <fdrake@acm.org>
Thu, 2 May 2002 18:13:48 +0000 (18:13 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 2 May 2002 18:13:48 +0000 (18:13 +0000)
(but not removed!) features of the xrange object.  This test should be
maintained for all of 2.2.x to avoid regression failures.

Lib/test/test_b2.py

index 6c14ccd47152e45c9a00ca028869a713745c2d1f..73d937f1245125620b3c8b81771aca637dd0db6e 100644 (file)
@@ -296,6 +296,20 @@ if r.tolist() != range(10, 3, -1):
 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'
+# regression tests for SourceForge bug #221965
+def _range_test(r):
+    verify(r.start != r.stop, 'Test not valid for passed-in xrange object.')
+    if r.stop in r:
+        raise TestFailed, 'r.stop in ' + `r`
+    if r.stop-r.step not in r:
+        raise TestFailed, 'r.stop-r.step not in ' + `r`
+    if r.start not in r:
+        raise TestFailed, 'r.start not in ' + `r`
+    if r.stop+r.step in r:
+        raise TestFailed, 'r.stop+r.step in ' + `r`
+_range_test(xrange(10))
+_range_test(xrange(9, -1, -1))
+_range_test(xrange(0, 10, 2))
 
 print 'zip'
 a = (1, 2, 3)