-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-143866: Verify return value of pathlib write methods in tests #143870
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,10 +70,14 @@ def test_write_bytes(self): | |
| # 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') | ||
| # check the return value | ||
| data = b'some bytes' | ||
| self.assertEqual(len(data), p.write_bytes(data)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we do the same here and move the check to the line 68?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes i will
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will fix the CI. |
||
|
|
||
| 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') | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.