-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
bpo-41546: make pprint (like print) not write to stdout when it is None #26810
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
Changes from 1 commit
69741ec
793fba5
214fb4f
be4404e
db4e471
62af033
fba7e43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| import collections | ||
| import contextlib | ||
| import dataclasses | ||
| import io | ||
| import itertools | ||
|
|
@@ -159,6 +160,10 @@ def test_basic(self): | |
| self.assertTrue(pp.isreadable(safe), | ||
| "expected isreadable for %r" % (safe,)) | ||
|
|
||
| def test_stdout_is_None(self): | ||
| with contextlib.redirect_stdout(None): | ||
| pprint.pprint('this should not fail') | ||
|
|
||
| def test_knotted(self): | ||
| # Verify .isrecursive() and .isreadable() w/ recursion | ||
| # Tie a knot. | ||
|
|
@@ -241,6 +246,9 @@ def test_same_as_repr(self): | |
| .replace('\n', ' '), native) | ||
| self.assertEqual(pprint.pformat(simple, underscore_numbers=True), native) | ||
| self.assertEqual(pprint.saferepr(simple), native) | ||
| with contextlib.redirect_stdout(None): | ||
| # smoke test - there is no output to check | ||
| pprint.pprint(simple) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is not it already tested in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, this is no longer needed, I'll remove. With my first (more complex) solution this covered more code paths. |
||
|
|
||
| def test_container_repr_override_called(self): | ||
| N = 1000 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.