mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-2122: Make mmap.flush() behave same on all platforms (GH-8692)
Previously, its behavior was platform-dependent and there was no error checking under Windows.
This commit is contained in:
parent
28853a249b
commit
e7d4b2f205
5 changed files with 36 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
from test.support import (TESTFN, run_unittest, import_module, unlink,
|
||||
from test.support import (TESTFN, import_module, unlink,
|
||||
requires, _2G, _4G, gc_collect, cpython_only)
|
||||
import unittest
|
||||
import os
|
||||
|
@ -741,6 +741,18 @@ class MmapTests(unittest.TestCase):
|
|||
with self.assertRaises(TypeError):
|
||||
m * 2
|
||||
|
||||
def test_flush_return_value(self):
|
||||
# mm.flush() should return None on success, raise an
|
||||
# exception on error under all platforms.
|
||||
mm = mmap.mmap(-1, 16)
|
||||
self.addCleanup(mm.close)
|
||||
mm.write(b'python')
|
||||
result = mm.flush()
|
||||
self.assertIsNone(result)
|
||||
if os.name != 'nt':
|
||||
# 'offset' must be a multiple of mmap.PAGESIZE.
|
||||
self.assertRaises(OSError, mm.flush, 1, len(b'python'))
|
||||
|
||||
|
||||
class LargeMmapTests(unittest.TestCase):
|
||||
|
||||
|
@ -803,8 +815,5 @@ class LargeMmapTests(unittest.TestCase):
|
|||
self._test_around_boundary(_4G)
|
||||
|
||||
|
||||
def test_main():
|
||||
run_unittest(MmapTests, LargeMmapTests)
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_main()
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue