-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
gh-129205: Modernize test_eintr #129316
base: main
Are you sure you want to change the base?
gh-129205: Modernize test_eintr #129316
Conversation
vstinner
commented
Jan 26, 2025
•
edited by bedevere-app
bot
Loading
edited by bedevere-app
bot
- Use f-string.
- Fix grammar: replace 'datas' with 'data' (and replace 'data' with 'item').
- Remove unused variables: 'pid' and 'old_mask'.
- Issue: Add os.readinto API for reading data into a caller provided buffer #129205
* Use f-string. * Fix grammar: replace 'datas' with 'data' (and replace 'data' with 'item'). * Remove unused variables: 'pid' and 'old_mask'.
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.
Definitely more modern. I duplicated a lot of code between test_read
and test_readinto
in GH-129211 I'm planning to dedupe (cmaloney@ad161bc#diff-60657ac311c452c61e0a872c2d0c7b6e763196617d65cfb3a7f73d791c922271L126). Happy to do that separately or could be incorporated here.
Might be out of scope, but the:
proc = self.subprocess(*args, **kwargs)
with kill_on_error(proc)
...
self.assertEqual(proc.wait(), 0)
across cases I think could be deduplicated with a context manager:
with self.checked_subprocess(code, *args, **kwargs):
...
@@ -130,26 +130,26 @@ def test_read(self): | |||
|
|||
# the payload below are smaller than PIPE_BUF, hence the writes will be | |||
# atomic | |||
datas = [b"hello", b"world", b"spam"] |
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
@@ -195,8 +195,8 @@ def test_write(self): | |||
'import io, os, sys, time', | |||
'', | |||
'rd = int(sys.argv[1])', | |||
'sleep_time = %r' % self.sleep_time, | |||
'data = b"x" * %s' % support.PIPE_MAX_SIZE, | |||
f'sleep_time = {self.sleep_time!r}', |
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.
nit: would it make sense to centralize the "make a string which sets sleep_time" (f'sleep_time = {self.sleep_time!r}'
) rather than the number of copies? (Possibly also data as well?)
Definitely nice having all the code for a test case in one place though, but feels fairly templated/repeated in structure at the moment.