https://github.com/python/cpython/commit/ea18782814d9d81cff6a66ddf3c056bacbf3bae7
commit: ea18782814d9d81cff6a66ddf3c056bacbf3bae7
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-01-19T11:50:54Z
summary:

[3.14] gh-143866: Verify return value of `pathlib.write_{bytes,text}` methods 
in tests (GH-143870) (#144029)

gh-143866: Verify return value of `pathlib.write_{bytes,text}` methods in tests 
(GH-143870)
(cherry picked from commit cb6a662bb0f7a9da9d4ba9dda820053f8d54a9f8)

Co-authored-by: b9788213 <[email protected]>
Co-authored-by: sobolevn <[email protected]>

files:
M Lib/test/test_pathlib/test_write.py

diff --git a/Lib/test/test_pathlib/test_write.py 
b/Lib/test/test_pathlib/test_write.py
index b958490d0a834f..15054e804ec9fd 100644
--- a/Lib/test/test_pathlib/test_write.py
+++ b/Lib/test/test_pathlib/test_write.py
@@ -59,15 +59,17 @@ def test_open_wb(self):
 
     def test_write_bytes(self):
         p = self.root / 'fileA'
-        p.write_bytes(b'abcdefg')
-        self.assertEqual(self.ground.readbytes(p), b'abcdefg')
+        data = b'abcdefg'
+        self.assertEqual(len(data), p.write_bytes(data))
+        self.assertEqual(self.ground.readbytes(p), data)
         # Check that trying to write str does not truncate the file.
         self.assertRaises(TypeError, p.write_bytes, 'somestr')
-        self.assertEqual(self.ground.readbytes(p), b'abcdefg')
+        self.assertEqual(self.ground.readbytes(p), data)
 
     def test_write_text(self):
         p = self.root / 'fileA'
-        p.write_text('äbcdefg', encoding='latin-1')
+        data = 'äbcdefg'
+        self.assertEqual(len(data), p.write_text(data, encoding='latin-1'))
         self.assertEqual(self.ground.readbytes(p), b'\xe4bcdefg')
         # Check that trying to write bytes does not truncate the file.
         self.assertRaises(TypeError, p.write_text, b'somebytes', 
encoding='utf-8')

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to