@@ -451,7 +451,7 @@ def testBytesOpen(self):
451
451
try :
452
452
f .write (b"abc" )
453
453
f .close ()
454
- with open (TESTFN_ASCII , "rb" ) as f :
454
+ with self . open (TESTFN_ASCII , "rb" ) as f :
455
455
self .assertEqual (f .read (), b"abc" )
456
456
finally :
457
457
os .unlink (TESTFN_ASCII )
@@ -468,7 +468,7 @@ def testUtf8BytesOpen(self):
468
468
try :
469
469
f .write (b"abc" )
470
470
f .close ()
471
- with open (TESTFN_UNICODE , "rb" ) as f :
471
+ with self . open (TESTFN_UNICODE , "rb" ) as f :
472
472
self .assertEqual (f .read (), b"abc" )
473
473
finally :
474
474
os .unlink (TESTFN_UNICODE )
@@ -552,13 +552,13 @@ def bug801631():
552
552
553
553
def testAppend (self ):
554
554
try :
555
- f = open (TESTFN , 'wb' )
555
+ f = self . FileIO (TESTFN , 'wb' )
556
556
f .write (b'spam' )
557
557
f .close ()
558
- f = open (TESTFN , 'ab' )
558
+ f = self . FileIO (TESTFN , 'ab' )
559
559
f .write (b'eggs' )
560
560
f .close ()
561
- f = open (TESTFN , 'rb' )
561
+ f = self . FileIO (TESTFN , 'rb' )
562
562
d = f .read ()
563
563
f .close ()
564
564
self .assertEqual (d , b'spameggs' )
@@ -594,6 +594,7 @@ def __setattr__(self, name, value):
594
594
class COtherFileTests (OtherFileTests , unittest .TestCase ):
595
595
FileIO = _io .FileIO
596
596
modulename = '_io'
597
+ open = _io .open
597
598
598
599
@cpython_only
599
600
def testInvalidFd_overflow (self ):
@@ -615,6 +616,7 @@ def test_open_code(self):
615
616
class PyOtherFileTests (OtherFileTests , unittest .TestCase ):
616
617
FileIO = _pyio .FileIO
617
618
modulename = '_pyio'
619
+ open = _pyio .open
618
620
619
621
def test_open_code (self ):
620
622
# Check that the default behaviour of open_code matches
0 commit comments