summaryrefslogtreecommitdiff
path: root/Lib/test/test_mmap.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2018-08-22 21:21:05 +0300
committerGitHub <noreply@github.com>2018-08-22 21:21:05 +0300
commite7d4b2f205c711d056bea73a0093e2e2b200544b (patch)
tree3a442a760dd83416b2141757f4bf546b623b6f36 /Lib/test/test_mmap.py
parent28853a249b1d0c890b7e9ca345290bb8c1756446 (diff)
downloadcpython-git-e7d4b2f205c711d056bea73a0093e2e2b200544b.tar.gz
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.
Diffstat (limited to 'Lib/test/test_mmap.py')
-rw-r--r--Lib/test/test_mmap.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 355af8cd58..d513810b35 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -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()