Skip to content

gh-89722: Add tests for pprint.pprint#95281

Closed
hp310780 wants to merge 4 commits into
python:mainfrom
hp310780:fix-issue-89722
Closed

gh-89722: Add tests for pprint.pprint#95281
hp310780 wants to merge 4 commits into
python:mainfrom
hp310780:fix-issue-89722

Conversation

@hp310780
Copy link
Copy Markdown

@hp310780 hp310780 commented Jul 26, 2022

Add tests for pprint.pprint arguments indent, width, depth, compact, sort_dicts and underscore_numbers.

@ghost
Copy link
Copy Markdown

ghost commented Jul 26, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-bot
Copy link
Copy Markdown

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@bedevere-bot bedevere-bot added awaiting review tests Tests in the Lib/test dir labels Jul 26, 2022
Comment thread Lib/test/test_pprint.py
'third': 3}]"""
self.assertEqual(pprint.pformat(o, indent=4, width=41), expected)

expected = "[ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],\n" \
Copy link
Copy Markdown
Member

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.

@ericvsmith
Copy link
Copy Markdown
Member

The full signature would probably be (self, expected, object, indent=1, width=80, depth=None, *, compact=False, sort_dicts=True, underscore_numbers=False). I'm not sure what order makes the most sense for expected and object.

@Privat33r-dev
Copy link
Copy Markdown
Contributor

@hp310780 thanks for your contribution. Any plans to continue your work on it?

@hp310780
Copy link
Copy Markdown
Author

hp310780 commented Jul 1, 2024

@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?

@Privat33r-dev
Copy link
Copy Markdown
Contributor

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.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented Apr 18, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 11, 2026
@hp310780 hp310780 closed this Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time. tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants