Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jan 26, 2025

  • Use f-string.
  • Fix grammar: replace 'datas' with 'data' (and replace 'data' with 'item').
  • Remove unused variables: 'pid' and 'old_mask'.

* Use f-string.
* Fix grammar: replace 'datas' with 'data' (and replace 'data' with
  'item').
* Remove unused variables: 'pid' and 'old_mask'.
@vstinner
Copy link
Member Author

cc @picnixz @cmaloney

Copy link
Contributor

@cmaloney cmaloney left a 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.

@@ -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}',
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants