diff options
author | Jesus Cea <jcea@jcea.es> | 2012-09-10 20:50:21 (GMT) |
---|---|---|
committer | Jesus Cea <jcea@jcea.es> | 2012-09-10 20:50:21 (GMT) |
commit | 4886d5b3385800cb302336b1ec3153833345226e (patch) | |
tree | bfa0fc5e526e007751f68c560d8adb8f7e2bd3f5 /Lib/test/test_mmap.py | |
parent | 7b9c48f3398468b28d6659844e0e9c0c8e9771fa (diff) | |
parent | 1f2799bef45673419e96ad4ef6a923c59d1c6a85 (diff) | |
download | cpython-4886d5b3385800cb302336b1ec3153833345226e.zip cpython-4886d5b3385800cb302336b1ec3153833345226e.tar.gz cpython-4886d5b3385800cb302336b1ec3153833345226e.tar.bz2 |
#15676: mmap: add empty file check prior to offset check <- Previous patch was incomplete
Diffstat (limited to 'Lib/test/test_mmap.py')
-rw-r--r-- | Lib/test/test_mmap.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 404f1e8..a3de398 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -491,11 +491,11 @@ class MmapTests(unittest.TestCase): 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() + with open(TESTFN, "rb") as f : + self.assertRaisesRegex(ValueError, + "cannot mmap an empty file", + mmap.mmap, f.fileno(), 0, + access=mmap.ACCESS_READ) def test_offset (self): f = open (TESTFN, 'w+b') |