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

bpo-36624: Add platform constants in test.support #13648

Closed
wants to merge 4 commits into from

Conversation

taleinat
Copy link
Contributor

@taleinat taleinat commented May 29, 2019

Add platform constants in Lib/test/support.py: support.MS_WINDOWS, support.AIX, etc.

This is a clean rebase of the original PR by @aixtools, GH-12843.

I've also fixed two minor errors which broke test_stat and test_subprocess.

https://bugs.python.org/issue36624

@@ -4862,7 +4862,7 @@ def test_c_context_errors(self):
for attr in ('prec', 'Emin', 'Emax', 'capitals', 'clamp'):
self.assertRaises(OverflowError, setattr, c, attr, int_max+1)
self.assertRaises(OverflowError, setattr, c, attr, -int_max-2)
if sys.platform != 'win32':
if not MS_WINDOWS:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that this adds a lot of clarity. Could you remove that?

Copy link
Contributor

@aixtools aixtools May 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not about just this one file. The request was, as much as possible, to use constants in the tests rather than different approaches such as 'sys.platform.startswith("win")' and sys.platform == 'win32'.

Compare with (if pasting images works)
image
Otherwise:

Look at this file (Lib/test/_test_multiprocessing.py, https://github.com/python/cpython/pull/13648/files#diff-b046ab474480855fb4a01de88cfc82bb) - where, for windows both a local constant (WIN32) and sys.platform {==|!=} 'win32' is used.

imho - this adds clarity to the whole.

@aixtools
Copy link
Contributor

Add platform constants in Lib/test/support.py: support.MS_WINDOWS, support.AIX, etc.

This is a clean rebase of the original PR by @aixtools, GH-12843.

I've also fixed two minor errors which broke test_stat and test_subprocess.

https://bugs.python.org/issue36624

Many thanks for the rebase - and corrections!

@skrah
Copy link
Contributor

skrah commented May 29, 2019

I'm a bit uncertain about the benefit of these in test.support. In other locations like setup.py one still needs sys.platform == name, which IMO is actually quite nice. So I don't feel a need to replace it.

Copy link
Contributor

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for asyncio part

Copy link
Contributor

@skrah skrah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you take out test_decimal? I don't quite like this change.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@skrah
Copy link
Contributor

skrah commented May 29, 2019 via email

@aixtools
Copy link
Contributor

Could you take out test_decimal? I don't quite like this change.

As I tried to show above - it is not just one file. IMHO - this needs to be unanimous. Without that there is no future where a code review could say - use constants.

And, yes, some platforms such as bsd* and solaris do not have constants - yet.

"My" intent is that they are also done - asap. Where there is a will, there is way.

@aixtools
Copy link
Contributor

aixtools commented May 29, 2019

On Wed, May 29, 2019 at 02:43:16AM -0700, Michael Felt wrote: imho - this adds clarity to the whole.
I don't think so: Now I have to wonder which of the different idioms hides behind MS_WINDOWS. And in other project's setup.py files I still need sys.platform, so now there's even one additional way to accomplish the same thing.

So, Python does nothing?

Doing this in "test" gives "the example" on how it should be done.

As to the areas outside of test, and even within test (e.g., for bsd*) I am willing to make this "my mission" to bring uniformity wherever possible. This was not even my idea :) - this was a suggestion on how I could contribute something to the whole.

Again, if not clear before - I do not see it stopping here - but would clearly welcome direction on where to set priorities.

It is not my call - I am not in python-dev mailing list - so I will not see a discussion there. If the group feels this is wrong - I have no direct interest in any decision made - other than my attempt - read desire - to contribute to Python.

Regards,
Michael

@taleinat
Copy link
Contributor Author

taleinat commented May 29, 2019

Considering this is a rather minor change, discussion about it should be done on the bug tracker, bpo-36624 (except when discussion specifics of the implementation in this PR).

@skrah, your input would be helpful there.

@aixtools, you've made your point rather clearly, let's see what some other devs think about this now that there's a PR to look at.

@skrah
Copy link
Contributor

skrah commented May 29, 2019

@taleinat I'm aware of the bug tracker.

@taleinat
Copy link
Contributor Author

@skrah, I have no doubt about that :)

I wanted to stop the discussion from continuing here where it could be missed by those following the issue on the bug tracker, so I wrote to clarify for everyone.

@ned-deily
Copy link
Member

@taleinat, FWIW, I disagree wih your assertion that this is a "rather minor change". See my comments on the bug tracker issue.

@taleinat
Copy link
Contributor Author

taleinat commented Jul 3, 2019

The discussion here and on the issue is clearly going towards not making this change, so I'm closing this PR.

@taleinat taleinat closed this Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants