]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 30 Jun 2025 22:19:14 +0000 (00:19 +0200)
committerGitHub <noreply@github.com>
Mon, 30 Jun 2025 22:19:14 +0000 (22:19 +0000)
gh-133982: Use implementation-specific `open` in `test_fileio.OtherFileTests` (GH-135364)
(cherry picked from commit 23caccf74ce2c8dc5d9c5eb6350d21ef20c6ea0b)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Lib/test/test_fileio.py

index 0611d1749f41c156cab8c517d783385c2af56a3d..fdb36ed997d046b690f97f48b98d5e985f4ac8fd 100644 (file)
@@ -451,7 +451,7 @@ class OtherFileTests:
         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)
@@ -468,7 +468,7 @@ class OtherFileTests:
         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)
@@ -552,13 +552,13 @@ class OtherFileTests:
 
     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')
@@ -594,6 +594,7 @@ class OtherFileTests:
 class COtherFileTests(OtherFileTests, unittest.TestCase):
     FileIO = _io.FileIO
     modulename = '_io'
+    open = _io.open
 
     @cpython_only
     def testInvalidFd_overflow(self):
@@ -615,6 +616,7 @@ class COtherFileTests(OtherFileTests, unittest.TestCase):
 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