diff options
author | Jesus Cea <jcea@jcea.es> | 2012-09-09 23:23:05 (GMT) |
---|---|---|
committer | Jesus Cea <jcea@jcea.es> | 2012-09-09 23:23:05 (GMT) |
commit | 1b3f3b03164fb4b273dd710899adf11b47480231 (patch) | |
tree | fccfe0ceaa332424a2c6756481584abd31bf72c1 /Lib/test/test_mmap.py | |
parent | b21d48dabf40b5adc64c8968322c5974b6f4e572 (diff) | |
parent | 941bfcc537a25077e2a73ddf8d8b3bfe288c81f4 (diff) | |
download | cpython-1b3f3b03164fb4b273dd710899adf11b47480231.zip cpython-1b3f3b03164fb4b273dd710899adf11b47480231.tar.gz cpython-1b3f3b03164fb4b273dd710899adf11b47480231.tar.bz2 |
Closes #15676: mmap: add empty file check prior to offset check
Diffstat (limited to 'Lib/test/test_mmap.py')
-rw-r--r-- | Lib/test/test_mmap.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 2230028..404f1e8 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -488,6 +488,15 @@ class MmapTests(unittest.TestCase): f.flush () return mmap.mmap (f.fileno(), 0) + def test_empty_file (self): + f = open (TESTFN, 'w+b') + f.close() + f = open(TESTFN, "rb") + self.assertRaisesRegex(ValueError, + "cannot mmap an empty file", + mmap.mmap, f.fileno(), 0, access=mmap.ACCESS_READ) + f.close() + def test_offset (self): f = open (TESTFN, 'w+b') |