@@ -663,27 +663,26 @@ def setUp(self):
663663 def tearDown (self ):
664664 unlink (TESTFN )
665665
666- def _create_test_file (self , num_zeroes , tail ):
666+ def _make_test_file (self , num_zeroes , tail ):
667667 if sys .platform [:3 ] == 'win' or sys .platform == 'darwin' :
668668 requires ('largefile' ,
669669 'test requires %s bytes and a long time to run' % str (0x180000000 ))
670- with open (TESTFN , 'wb' ) as f :
671- try :
672- f .seek (num_zeroes )
673- f .write (tail )
674- f .flush ()
675- except (IOError , OverflowError ):
676- raise unittest .SkipTest ("filesystem does not have largefile support" )
670+ f = open (TESTFN , 'w+b' )
671+ try :
672+ f .seek (num_zeroes )
673+ f .write (tail )
674+ f .flush ()
675+ except (IOError , OverflowError ):
676+ raise unittest .SkipTest ("filesystem does not have largefile support" )
677+ return f
677678
678679 def test_large_offset (self ):
679- self ._create_test_file (0x14FFFFFFF , b" " )
680- with open (TESTFN , 'rb' ) as f :
680+ with self ._make_test_file (0x14FFFFFFF , b" " ) as f :
681681 with mmap .mmap (f .fileno (), 0 , offset = 0x140000000 , access = mmap .ACCESS_READ ) as m :
682682 self .assertEqual (m [0xFFFFFFF ], 32 )
683683
684684 def test_large_filesize (self ):
685- self ._create_test_file (0x17FFFFFFF , b" " )
686- with open (TESTFN , 'rb' ) as f :
685+ with self ._make_test_file (0x17FFFFFFF , b" " ) as f :
687686 with mmap .mmap (f .fileno (), 0x10000 , access = mmap .ACCESS_READ ) as m :
688687 self .assertEqual (m .size (), 0x180000000 )
689688
@@ -693,8 +692,7 @@ def _test_around_boundary(self, boundary):
693692 tail = b' DEARdear '
694693 start = boundary - len (tail ) // 2
695694 end = start + len (tail )
696- self ._create_test_file (start , tail )
697- with open (TESTFN , 'rb' ) as f :
695+ with self ._make_test_file (start , tail ) as f :
698696 with mmap .mmap (f .fileno (), 0 , access = mmap .ACCESS_READ ) as m :
699697 self .assertEqual (m [start :end ], tail )
700698
0 commit comments