Skip to content

Commit 8b4a3d2

Browse files
committed
fix up test case
1 parent e38cd0f commit 8b4a3d2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Lib/test/test_mmap.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,17 @@ def test_find_end(self):
302302
def test_find_does_not_access_beyond_buffer(self):
303303
try:
304304
flags = mmap.MAP_PRIVATE | mmap.MAP_ANONYMOUS
305-
except AttributeError:
306-
raise unittest.SkipTest("mmap flags unavailable")
305+
PAGESIZE = mmap.PAGESIZE
306+
PROT_NONE = 0
307+
PROT_READ = mmap.PROT_READ
308+
except AttributeError as e:
309+
raise unittest.SkipTest("mmap flags unavailable") from e
307310
for i in range(0, 2049):
308-
with mmap.mmap(0, 4096 * (i + 1), flags=flags, prot=0) as guard:
309-
with mmap.mmap(0, 8388608 + 4096 * i, flags=flags, prot=mmap.PROT_READ) as fm:
310-
fm.find(b"fo")
311+
with mmap.mmap(-1, PAGESIZE * (i + 1),
312+
flags=flags, prot=PROT_NONE) as guard:
313+
with mmap.mmap(-1, PAGESIZE * (i + 2048),
314+
flags=flags, prot=PROT_READ) as fm:
315+
fm.find(b"fo", -2)
311316

312317
def test_rfind(self):
313318
# test the new 'end' parameter works as expected

0 commit comments

Comments
 (0)