diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2000-06-18 04:47:08 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2000-06-18 04:47:08 (GMT) |
commit | cf70ea633f24c8318e25891c45efd7710466eacb (patch) | |
tree | 606a45466dd475374427236637010edee673476d /Lib/test | |
parent | 70d2742fce9c971fffc2f0c25c93b7686da84f60 (diff) | |
download | cpython-cf70ea633f24c8318e25891c45efd7710466eacb.zip cpython-cf70ea633f24c8318e25891c45efd7710466eacb.tar.gz cpython-cf70ea633f24c8318e25891c45efd7710466eacb.tar.bz2 |
Additional tests for seek() method, written by Trent Mick
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/output/test_mmap | bin | 346 -> 520 bytes | |||
-rw-r--r-- | Lib/test/test_mmap.py | 37 |
2 files changed, 36 insertions, 1 deletions
diff --git a/Lib/test/output/test_mmap b/Lib/test/output/test_mmap Binary files differindex f3efcd0..0e880e3 100644 --- a/Lib/test/output/test_mmap +++ b/Lib/test/output/test_mmap diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index e5da187..c3cafca 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' |