-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-89722: Add tests for pprint.pprint #95281
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
base: main
Are you sure you want to change the base?
Conversation
…derscore_numbers arguments
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
@@ -327,6 +327,12 @@ def test_nested_indentations(self): | |||
'third': 3}]""" | |||
self.assertEqual(pprint.pformat(o, indent=4, width=41), expected) | |||
|
|||
expected = "[ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],\n" \ |
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 you can write a helper function, something like assert_pprint(self, obj, expected, indent=1, width=80, depth=None)
(mirroring the defaults of pprint.pprint
), that then tests both pprint.pformat
to a string and pprint,pprint
to a stream. Then use it everywhere instead of duplicating the expected values everywhere. You'll probably need to ignore the trailing newline on the stream version.
The full signature would probably be |
@hp310780 thanks for your contribution. Any plans to continue your work on it? |
Hi there! Many apologies, I was restricted from open source due to some work legalities, but this is no longer the case. I see that this PR is still active with other contributions. Should I continue? |
That's not a problem, no pressure here :) It would be great if you can continue. |
Add tests for pprint.pprint arguments indent, width, depth, compact, sort_dicts and underscore_numbers.