https://github.com/python/cpython/commit/028901e97ffb7c10fb07fbe45229c4f37ee6067d
commit: 028901e97ffb7c10fb07fbe45229c4f37ee6067d
branch: 3.14
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: ZeroIntensity <zintensity...@gmail.com>
date: 2025-06-30T22:23:34Z
summary:

[3.14] gh-133982: Use implementation-specific `open` in 
`test_fileio.OtherFileTests` (GH-135364) (GH-136148)

gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests` 
(GH-135364)
(cherry picked from commit 23caccf74ce2c8dc5d9c5eb6350d21ef20c6ea0b)

Co-authored-by: Cody Maloney <cmalo...@users.noreply.github.com>

files:
M Lib/test/test_fileio.py

diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index 5a0f033ebb82d2..e3d54f6315aade 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -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)
@@ -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)
@@ -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')
@@ -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):
@@ -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

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: arch...@mail-archive.com

Reply via email to