Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(164330)

Side by Side Diff: Lib/test/test_mmap.py

Issue 26335: Make mmap.write return the number of bytes written like other write methods
Patch Set: Created 3 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 from test.support import (TESTFN, run_unittest, import_module, unlink, 1 from test.support import (TESTFN, run_unittest, import_module, unlink,
2 requires, _2G, _4G, gc_collect, cpython_only) 2 requires, _2G, _4G, gc_collect, cpython_only)
3 import unittest 3 import unittest
4 import os 4 import os
5 import re 5 import re
6 import itertools 6 import itertools
7 import socket 7 import socket
8 import sys 8 import sys
9 import weakref 9 import weakref
10 10
(...skipping 14 matching lines...) Expand all
25 except OSError: 25 except OSError:
26 pass 26 pass
27 27
28 def test_basic(self): 28 def test_basic(self):
29 # Test mmap module on Unix systems and Windows 29 # Test mmap module on Unix systems and Windows
30 30
31 # Create a file to be mmap'ed. 31 # Create a file to be mmap'ed.
32 f = open(TESTFN, 'bw+') 32 f = open(TESTFN, 'bw+')
33 try: 33 try:
34 # Write 2 pages worth of data to the file 34 # Write 2 pages worth of data to the file
35 f.write(b'\0'* PAGESIZE) 35 self.assertEqual(f.write(b'\0'* PAGESIZE), PAGESIZE)
berkerpeksag 2016/02/23 00:57:52 I'd prefer to keep existed tests as they are and a
36 f.write(b'foo') 36 self.assertEqual(f.write(b'foo'), 3)
37 f.write(b'\0'* (PAGESIZE-3) ) 37 self.assertEqual(f.write(b'\0'* (PAGESIZE-3) ), PAGESIZE - 3)
38 f.flush() 38 f.flush()
39 m = mmap.mmap(f.fileno(), 2 * PAGESIZE) 39 m = mmap.mmap(f.fileno(), 2 * PAGESIZE)
40 finally: 40 finally:
41 f.close() 41 f.close()
42 42
43 # Simple sanity checks 43 # Simple sanity checks
44 44
45 tp = str(type(m)) # SF bug 128713: segfaulted on Linux 45 tp = str(type(m)) # SF bug 128713: segfaulted on Linux
46 self.assertEqual(m.find(b'foo'), PAGESIZE) 46 self.assertEqual(m.find(b'foo'), PAGESIZE)
47 47
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 @unittest.skipUnless(sys.maxsize > _4G, "test cannot run on 32-bit systems") 772 @unittest.skipUnless(sys.maxsize > _4G, "test cannot run on 32-bit systems")
773 def test_around_4GB(self): 773 def test_around_4GB(self):
774 self._test_around_boundary(_4G) 774 self._test_around_boundary(_4G)
775 775
776 776
777 def test_main(): 777 def test_main():
778 run_unittest(MmapTests, LargeMmapTests) 778 run_unittest(MmapTests, LargeMmapTests)
779 779
780 if __name__ == '__main__': 780 if __name__ == '__main__':
781 test_main() 781 test_main()
OLDNEW

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+