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

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

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 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
« no previous file with comments | « Lib/test/test_minidom.py ('k') | Lib/test/test_multiprocessing.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) 2 requires, _2G, _4G)
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 9
10 # Skip test if we can't import mmap. 10 # Skip test if we can't import mmap.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 # would then be different across platforms. 101 # would then be different across platforms.
102 pass 102 pass
103 else: 103 else:
104 # resize() is supported 104 # resize() is supported
105 self.assertEqual(len(m), 512) 105 self.assertEqual(len(m), 512)
106 # Check that we can no longer seek beyond the new size. 106 # Check that we can no longer seek beyond the new size.
107 self.assertRaises(ValueError, m.seek, 513, 0) 107 self.assertRaises(ValueError, m.seek, 513, 0)
108 108
109 # Check that the underlying file is truncated too 109 # Check that the underlying file is truncated too
110 # (bug #728515) 110 # (bug #728515)
111 f = open(TESTFN, 'rb') 111 f = open(TESTFN)
112 try: 112 try:
113 f.seek(0, 2) 113 f.seek(0, 2)
114 self.assertEqual(f.tell(), 512) 114 self.assertEqual(f.tell(), 512)
115 finally: 115 finally:
116 f.close() 116 f.close()
117 self.assertEqual(m.size(), 512) 117 self.assertEqual(m.size(), 512)
118 118
119 m.close() 119 m.close()
120 120
121 def test_access_parameter(self): 121 def test_access_parameter(self):
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 self.assertEqual(m.rfind(b'one', 1, -2), -1) 301 self.assertEqual(m.rfind(b'one', 1, -2), -1)
302 302
303 303
304 def test_double_close(self): 304 def test_double_close(self):
305 # make sure a double close doesn't crash on Solaris (Bug# 665913) 305 # make sure a double close doesn't crash on Solaris (Bug# 665913)
306 f = open(TESTFN, 'wb+') 306 f = open(TESTFN, 'wb+')
307 307
308 f.write(2**16 * b'a') # Arbitrary character 308 f.write(2**16 * b'a') # Arbitrary character
309 f.close() 309 f.close()
310 310
311 f = open(TESTFN, 'rb') 311 f = open(TESTFN)
312 mf = mmap.mmap(f.fileno(), 2**16, access=mmap.ACCESS_READ) 312 mf = mmap.mmap(f.fileno(), 2**16, access=mmap.ACCESS_READ)
313 mf.close() 313 mf.close()
314 mf.close() 314 mf.close()
315 f.close() 315 f.close()
316 316
317 def test_entire_file(self): 317 def test_entire_file(self):
318 # test mapping of entire file by passing 0 for map length 318 # test mapping of entire file by passing 0 for map length
319 if hasattr(os, "stat"): 319 if hasattr(os, "stat"):
320 f = open(TESTFN, "wb+") 320 f = open(TESTFN, "wb+")
321 321
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 pass 523 pass
524 else: 524 else:
525 # resize() is supported 525 # resize() is supported
526 self.assertEqual(len(m), 512) 526 self.assertEqual(len(m), 512)
527 # Check that we can no longer seek beyond the new size. 527 # Check that we can no longer seek beyond the new size.
528 self.assertRaises(ValueError, m.seek, 513, 0) 528 self.assertRaises(ValueError, m.seek, 513, 0)
529 # Check that the content is not changed 529 # Check that the content is not changed
530 self.assertEqual(m[0:3], b'foo') 530 self.assertEqual(m[0:3], b'foo')
531 531
532 # Check that the underlying file is truncated too 532 # Check that the underlying file is truncated too
533 f = open(TESTFN, 'rb') 533 f = open(TESTFN)
534 f.seek(0, 2) 534 f.seek(0, 2)
535 self.assertEqual(f.tell(), halfsize + 512) 535 self.assertEqual(f.tell(), halfsize + 512)
536 f.close() 536 f.close()
537 self.assertEqual(m.size(), halfsize + 512) 537 self.assertEqual(m.size(), halfsize + 512)
538 538
539 m.close() 539 m.close()
540 540
541 finally: 541 finally:
542 f.close() 542 f.close()
543 try: 543 try:
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 @unittest.skipUnless(sys.maxsize > _4G, "test cannot run on 32-bit systems") 733 @unittest.skipUnless(sys.maxsize > _4G, "test cannot run on 32-bit systems")
734 def test_around_4GB(self): 734 def test_around_4GB(self):
735 self._test_around_boundary(_4G) 735 self._test_around_boundary(_4G)
736 736
737 737
738 def test_main(): 738 def test_main():
739 run_unittest(MmapTests, LargeMmapTests) 739 run_unittest(MmapTests, LargeMmapTests)
740 740
741 if __name__ == '__main__': 741 if __name__ == '__main__':
742 test_main() 742 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_minidom.py ('k') | Lib/test/test_multiprocessing.py » ('j') | no next file with comments »

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