Skip to content

Commit 7b10663

Browse files
committed
Update test_pprint.py from CPython v3.12.0a0
1 parent b0f620c commit 7b10663

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Lib/test/test_pprint.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
import collections
4+
import contextlib
45
import dataclasses
56
import io
67
import itertools
@@ -159,6 +160,13 @@ def test_basic(self):
159160
self.assertTrue(pp.isreadable(safe),
160161
"expected isreadable for %r" % (safe,))
161162

163+
def test_stdout_is_None(self):
164+
with contextlib.redirect_stdout(None):
165+
# smoke test - there is no output to check
166+
value = 'this should not fail'
167+
pprint.pprint(value)
168+
pprint.PrettyPrinter().pprint(value)
169+
162170
def test_knotted(self):
163171
# Verify .isrecursive() and .isreadable() w/ recursion
164172
# Tie a knot.
@@ -195,7 +203,7 @@ def test_knotted(self):
195203
def test_unreadable(self):
196204
# Not recursive but not readable anyway
197205
pp = pprint.PrettyPrinter()
198-
for unreadable in type(3), pprint, pprint.isrecursive:
206+
for unreadable in object(), int, pprint, pprint.isrecursive:
199207
# module-level convenience functions
200208
self.assertFalse(pprint.isrecursive(unreadable),
201209
"expected not isrecursive for %r" % (unreadable,))
@@ -524,6 +532,8 @@ def test_dataclass_with_repr(self):
524532
formatted = pprint.pformat(dc, width=20)
525533
self.assertEqual(formatted, "custom repr that doesn't fit within pprint width")
526534

535+
# TODO: RUSTPYTHON
536+
@unittest.expectedFailure
527537
def test_dataclass_no_repr(self):
528538
dc = dataclass3()
529539
formatted = pprint.pformat(dc, width=10)

0 commit comments

Comments
 (0)