From cf70ea633f24c8318e25891c45efd7710466eacb Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Sun, 18 Jun 2000 04:47:08 +0000 Subject: [PATCH] Additional tests for seek() method, written by Trent Mick --- Lib/test/output/test_mmap | Bin 346 -> 520 bytes Lib/test/test_mmap.py | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Lib/test/output/test_mmap b/Lib/test/output/test_mmap index f3efcd06966dc024a1f97b4c8dfcd5377bd002ba..0e880e38cdf27398f248e705ef8d7f298bb07d11 100644 GIT binary patch delta 195 zcmcb`)WNdBkFj1MI5jm}p(J0SDzzxTBts#ovLuyD0WNA{l$U}omXlaq0uu`6%r4OvxEYGppq%v2!GPgAhY%}p%8R0K2K(_z@ delta 20 bcmeBRxy7`>kC7)NwYWr~AhEbOHH8ZRN9_i_ diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index e5da187e0c..c3cafca834 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -58,7 +58,42 @@ def test_both(): assert start == PAGESIZE assert end == PAGESIZE + 6 - + + # test seeking around (try to overflow the seek implementation) + m.seek(0,0) + print ' Seek to zeroth byte' + assert m.tell() == 0 + m.seek(42,1) + print ' Seek to 42nd byte' + assert m.tell() == 42 + m.seek(0,2) + print ' Seek to last byte' + assert m.tell() == len(m) + + print ' Try to seek to negative position...' + try: + m.seek(-1) + except ValueError: + pass + else: + assert 0, 'expected a ValueError but did not get it' + + print ' Try to seek beyond end of mmap...' + try: + m.seek(1,2) + except ValueError: + pass + else: + assert 0, 'expected a ValueError but did not get it' + + print ' Try to seek to negative position...' + try: + m.seek(-len(m)-1,2) + except ValueError: + pass + else: + assert 0, 'expected a ValueError but did not get it' + m.close() os.unlink("foo") print ' Test passed' -- 2.40.0