12 class QueryTestCase(unittest
.TestCase
):
20 """Verify .isrecursive() and .isreadable() w/o recursion."""
22 for safe
in (2, 2.0, 2j
, "abc", [3], (2,2), {3: 3}, uni("yaddayadda"),
24 verify(not pprint
.isrecursive(safe
),
25 "expected not isrecursive for " + `safe`
)
26 verify(pprint
.isreadable(safe
),
27 "expected isreadable for " + `safe`
)
29 def test_knotted(self
):
30 """Verify .isrecursive() and .isreadable() w/ recursion."""
35 self
.d
[0] = self
.d
[1] = self
.d
[2] = self
.d
39 for icky
in self
.a
, self
.b
, self
.d
, (self
.d
, self
.d
):
40 verify(pprint
.isrecursive(icky
), "expected isrecursive")
41 verify(not pprint
.isreadable(icky
), "expected not isreadable")
48 for safe
in self
.a
, self
.b
, self
.d
, (self
.d
, self
.d
):
49 verify(not pprint
.isrecursive(safe
),
50 "expected not isrecursive for " + `safe`
)
51 verify(pprint
.isreadable(safe
),
52 "expected isreadable for " + `safe`
)
54 def test_unreadable(self
):
55 """Not recursive but not readable anyway."""
57 for unreadable
in type(3), pprint
, pprint
.isrecursive
:
58 verify(not pprint
.isrecursive(unreadable
),
59 "expected not isrecursive for " + `unreadable`
)
60 verify(not pprint
.isreadable(unreadable
),
61 "expected not isreadable for " + `unreadable`
)
63 def test_same_as_repr(self
):
64 "Simple objects and small containers that should be same as repr()."
66 for simple
in (0, 0L, 0+0j
, 0.0, "", uni(""), (), [], {}, verify
, pprint
,
67 -6, -6L, -6-6j
, -1.5, "x", uni("x"), (3,), [3], {3: 6},
68 (1,2), [3,4], {5: 6, 7: 8},
69 {"xy\tab\n": (3,), 5: [[]], (): {}},
73 for function
in "pformat", "saferepr":
74 f
= getattr(pprint
, function
)
76 verify(native
== got
, "expected %s got %s from pprint.%s" %
77 (native
, got
, function
))
80 def test_basic_line_wrap(self
):
81 """verify basic line-wrapping operation"""
85 'controldesk_runtime_us': 0,
86 'main_code_runtime_us': 0,
87 'read_io_runtime_us': 0,
88 'write_io_runtime_us': 43690}
93 'controldesk_runtime_us': 0,
94 'main_code_runtime_us': 0,
95 'read_io_runtime_us': 0,
96 'write_io_runtime_us': 43690}"""
97 self
.assertEqual(pprint
.pformat(o
), exp
)
100 test_support
.run_unittest(QueryTestCase
)
103 if __name__
== "__main__":