@@ -451,7 +451,7 @@ def testBytesOpen(self):
451451 try :
452452 f .write (b"abc" )
453453 f .close ()
454- with open (TESTFN_ASCII , "rb" ) as f :
454+ with self . open (TESTFN_ASCII , "rb" ) as f :
455455 self .assertEqual (f .read (), b"abc" )
456456 finally :
457457 os .unlink (TESTFN_ASCII )
@@ -468,7 +468,7 @@ def testUtf8BytesOpen(self):
468468 try :
469469 f .write (b"abc" )
470470 f .close ()
471- with open (TESTFN_UNICODE , "rb" ) as f :
471+ with self . open (TESTFN_UNICODE , "rb" ) as f :
472472 self .assertEqual (f .read (), b"abc" )
473473 finally :
474474 os .unlink (TESTFN_UNICODE )
@@ -552,13 +552,13 @@ def bug801631():
552552
553553 def testAppend (self ):
554554 try :
555- f = open (TESTFN , 'wb' )
555+ f = self . FileIO (TESTFN , 'wb' )
556556 f .write (b'spam' )
557557 f .close ()
558- f = open (TESTFN , 'ab' )
558+ f = self . FileIO (TESTFN , 'ab' )
559559 f .write (b'eggs' )
560560 f .close ()
561- f = open (TESTFN , 'rb' )
561+ f = self . FileIO (TESTFN , 'rb' )
562562 d = f .read ()
563563 f .close ()
564564 self .assertEqual (d , b'spameggs' )
@@ -594,6 +594,7 @@ def __setattr__(self, name, value):
594594class COtherFileTests (OtherFileTests , unittest .TestCase ):
595595 FileIO = _io .FileIO
596596 modulename = '_io'
597+ open = _io .open
597598
598599 @cpython_only
599600 def testInvalidFd_overflow (self ):
@@ -615,6 +616,7 @@ def test_open_code(self):
615616class PyOtherFileTests (OtherFileTests , unittest .TestCase ):
616617 FileIO = _pyio .FileIO
617618 modulename = '_pyio'
619+ open = _pyio .open
618620
619621 def test_open_code (self ):
620622 # Check that the default behaviour of open_code matches
0 commit comments