Skip to content

gh-133982: Use implementation-specific open in test_fileio OtherFileTests #135364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Lib/test/test_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def testBytesOpen(self):
try:
f.write(b"abc")
f.close()
with open(TESTFN_ASCII, "rb") as f:
with self.open(TESTFN_ASCII, "rb") as f:
self.assertEqual(f.read(), b"abc")
finally:
os.unlink(TESTFN_ASCII)
Expand All @@ -608,7 +608,7 @@ def testUtf8BytesOpen(self):
try:
f.write(b"abc")
f.close()
with open(TESTFN_UNICODE, "rb") as f:
with self.open(TESTFN_UNICODE, "rb") as f:
self.assertEqual(f.read(), b"abc")
finally:
os.unlink(TESTFN_UNICODE)
Expand Down Expand Up @@ -692,13 +692,13 @@ def bug801631():

def testAppend(self):
try:
f = open(TESTFN, 'wb')
f = self.FileIO(TESTFN, 'wb')
f.write(b'spam')
f.close()
f = open(TESTFN, 'ab')
f = self.FileIO(TESTFN, 'ab')
f.write(b'eggs')
f.close()
f = open(TESTFN, 'rb')
f = self.FileIO(TESTFN, 'rb')
d = f.read()
f.close()
self.assertEqual(d, b'spameggs')
Expand Down Expand Up @@ -734,6 +734,7 @@ def __setattr__(self, name, value):
class COtherFileTests(OtherFileTests, unittest.TestCase):
FileIO = _io.FileIO
modulename = '_io'
open = _io.open

@cpython_only
def testInvalidFd_overflow(self):
Expand All @@ -755,6 +756,7 @@ def test_open_code(self):
class PyOtherFileTests(OtherFileTests, unittest.TestCase):
FileIO = _pyio.FileIO
modulename = '_pyio'
open = _pyio.open

def test_open_code(self):
# Check that the default behaviour of open_code matches
Expand Down
Loading