-
-
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?
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Ok, i am changed it. Can you add "skip news" label please? |
| self.assertEqual(self.ground.readbytes(p), b'abcdefg') | ||
| # check the return value | ||
| data = b'some bytes' | ||
| self.assertEqual(len(data), p.write_bytes(data)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes i will
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fix the CI.
|
Why its failing? |
Description
This PR adds assertions to ensure that
pathlib.Path.write_text()andpathlib.Path.write_bytes()correctly return the number of bytes written.Currently, the tests only verify the side effects (file content), which means a regression (like accidentally removing the
returnstatement) would go unnoticed.Linked Issue
Fixes #143866