@@ -591,7 +591,7 @@ def testBytesOpen(self):
591591 try :
592592 f .write (b"abc" )
593593 f .close ()
594- with open (TESTFN_ASCII , "rb" ) as f :
594+ with self . open (TESTFN_ASCII , "rb" ) as f :
595595 self .assertEqual (f .read (), b"abc" )
596596 finally :
597597 os .unlink (TESTFN_ASCII )
@@ -608,7 +608,7 @@ def testUtf8BytesOpen(self):
608608 try :
609609 f .write (b"abc" )
610610 f .close ()
611- with open (TESTFN_UNICODE , "rb" ) as f :
611+ with self . open (TESTFN_UNICODE , "rb" ) as f :
612612 self .assertEqual (f .read (), b"abc" )
613613 finally :
614614 os .unlink (TESTFN_UNICODE )
@@ -692,13 +692,13 @@ def bug801631():
692692
693693 def testAppend (self ):
694694 try :
695- f = open (TESTFN , 'wb' )
695+ f = self . FileIO (TESTFN , 'wb' )
696696 f .write (b'spam' )
697697 f .close ()
698- f = open (TESTFN , 'ab' )
698+ f = self . FileIO (TESTFN , 'ab' )
699699 f .write (b'eggs' )
700700 f .close ()
701- f = open (TESTFN , 'rb' )
701+ f = self . FileIO (TESTFN , 'rb' )
702702 d = f .read ()
703703 f .close ()
704704 self .assertEqual (d , b'spameggs' )
@@ -734,6 +734,7 @@ def __setattr__(self, name, value):
734734class COtherFileTests (OtherFileTests , unittest .TestCase ):
735735 FileIO = _io .FileIO
736736 modulename = '_io'
737+ open = _io .open
737738
738739 @cpython_only
739740 def testInvalidFd_overflow (self ):
@@ -755,6 +756,7 @@ def test_open_code(self):
755756class PyOtherFileTests (OtherFileTests , unittest .TestCase ):
756757 FileIO = _pyio .FileIO
757758 modulename = '_pyio'
759+ open = _pyio .open
758760
759761 def test_open_code (self ):
760762 # Check that the default behaviour of open_code matches
0 commit comments