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
test_argparse.py: use new unittest features #53763
Comments
Some of the unit testing code in test_argparse.py could be modified to take advantage of the new unittest features in Python 2.7 and 3.x. My suggested changes are attached in the patch file test_argparse.py.unittest2.patch One big one is that assertEquals() now prints a "diff" when multi-line strings compare unequal, so the manual "diffing" logic from the unit tests can be removed. Also, assertIsNone() is slightly better than assertEquals(None, x). Finally, there is a tiny fix where parse_args() was expected to throw ArgumentParserError but the test would not fail if it threw no exceptions. |
These all look like good changes to me. (I looked at the patch, but haven't tried applying it though.) |
Hi, I've applied the patch and it goes fine (except for some offsets and the fact it was generated inside Lib/test) and the tests are still all ok. I'd suggest to apply it. |
The patch is still valid - it applies ok. The only issues as mentioned by sandro.tosi are offsets and that it was generated inside Lib/ It would be worth having these changes applied. |
Another one: except ArgumentParserError:
err = sys.exc_info()[1] This reeks of single-codebase-for-2.x-and-3.x and could probably be replaced by assertRaises or at least a regular except...as. |
Hi Eric, Denver's patch should apply correctly from the root. Also, I've made the changes you mention: try: except: assert has been replaced by: with self.assertRaises() |
See also bpo-16510. |
Latest patch LGTM so can we have a commit review please. |
Updated patch to use assertRaisesRegex in test_invalid_action, test_multiple_dest |
Updated patch. |
New changeset f240ca6345c8 by Berker Peksag in branch 'default': |
Thanks Denver and Radu. And thanks for the review, Ezio. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: