-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
[Tests] Cleanup the tests of argparse. #11750
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
Conversation
Remove useless import, remove useless assignment variables and be pep8 compliant.
113bb22
to
ce8677a
Compare
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.
A few details.
As a general comment, one of the very important part of PEP 8 is at the very beginning:
"A Foolish Consistency is the Hobgoblin of Little Minds" (...) "However, know when to be inconsistent -- sometimes style guide recommendations just aren't applicable. " followed by "good reasons to ignore a particular guideline".
@@ -471,8 +479,7 @@ class TestOptionalsAlternatePrefixCharsMultipleShortArgs(ParserTestCase): | |||
'-xyz', | |||
'+x', | |||
'-y', | |||
'+xyz', | |||
] | |||
'+xyz'] |
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.
I think the original code is more idiomatic.
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.
I agree with @SylvainDe
argument_group_signatures = TestHelpBiggerOptionals.argument_group_signatures | ||
parser_signature = TestHelpBiggerOptionals.parser_signature | ||
argument_signatures = TestHelpBiggerOptionals.argument_signatures | ||
argument_group_signatures = TestHelpBiggerOptionals\ |
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 looked more beautiful before.
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.
I think that this change is good. IMO pep8 analyze should fail if we maintain the old style. Why never fail?
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.
I agree with @SylvainDe. Sometimes, fix pep8 problems will not be a good improve.
But core dev reviewers have the last word. :-)
Please review why the test are fail
@@ -425,7 +431,9 @@ class TestOptionalsAlternatePrefixChars(ParserTestCase): | |||
Sig('::bar'), | |||
Sig('/baz', action='store_const', const=42), | |||
] | |||
failures = ['--bar', '-fbar', '-b B', 'B', '-f', '--bar B', '-baz', '-h', '--help', '+h', '::help', '/help'] | |||
failures = [ |
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.
I think that is better use the first line to put values, and not start on new line. e.g.:
failures = [ '--bar', '-fbar', '-b B', 'B', '-f', '--bar B',
'-baz', '-h', '--help', '+h', '::help', '/help']
@@ -471,8 +479,7 @@ class TestOptionalsAlternatePrefixCharsMultipleShortArgs(ParserTestCase): | |||
'-xyz', | |||
'+x', | |||
'-y', | |||
'+xyz', | |||
] | |||
'+xyz'] |
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.
I agree with @SylvainDe
self.assertRaises(ArgumentParserError, parser.parse_args, | ||
['-y', 'Y', '-z', 'Z']) | ||
self.assertRaises( | ||
ArgumentParserError, parser.parse_args, ['-y', 'Y', '-z', 'Z']) |
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.
Before is better.
argument_group_signatures = TestHelpBiggerOptionals.argument_group_signatures | ||
parser_signature = TestHelpBiggerOptionals.parser_signature | ||
argument_signatures = TestHelpBiggerOptionals.argument_signatures | ||
argument_group_signatures = TestHelpBiggerOptionals\ |
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.
I think that this change is good. IMO pep8 analyze should fail if we maintain the old style. Why never fail?
class TestHelpVersionAction(HelpTestCase): | ||
"""Test the default help for the version action""" | ||
|
||
parser_signature = Sig(prog='PROG', description='description') | ||
argument_signatures = [Sig('-V', '--version', action='version', version='3.6')] | ||
argument_signatures = [Sig( | ||
'-V', '--version', action='version', version='3.6')] |
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.
Same of the comments above.
Thanks for the work, but we don't generally make bulk changes like this. It generates churn in the codebase, and has the risk of inadvertently changing the meaning of the tests, to little actual benefit. Instead we modernize tests when we touch them for other reasons and are in a position to confirm that the changes do not change the meaning of the tests. (I realize that for most of your changes the meaning is trivially preserved...but when you make a lot of changes you are almost certain to make some mistakes...thus the resistance to doing bulk updates.) As you can see, none of the continuous integration tests passed, which reinforces the fact that this change isn't as trivial as it may appear. For example, from the Travis check:
|
Remove useless import, remove useless assignment variables and be
pep8 compliant.