diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-05-14 07:05:58 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-05-14 07:05:58 (GMT) |
commit | a814db579db9cfcaa3cf2ca7bae539cf2c80a9f0 (patch) | |
tree | 6e96eb822db945a675a5e7a89a8ef3c22ba32150 /Lib/test/test_pprint.py | |
parent | 2a0af79269a19b4afc423c44f8b51c22fb8ad3a3 (diff) | |
download | cpython-a814db579db9cfcaa3cf2ca7bae539cf2c80a9f0.zip cpython-a814db579db9cfcaa3cf2ca7bae539cf2c80a9f0.tar.gz cpython-a814db579db9cfcaa3cf2ca7bae539cf2c80a9f0.tar.bz2 |
SF bug[ #423781: pprint.isrecursive() broken.
Diffstat (limited to 'Lib/test/test_pprint.py')
-rw-r--r-- | Lib/test/test_pprint.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py new file mode 100644 index 0000000..610e989 --- /dev/null +++ b/Lib/test/test_pprint.py @@ -0,0 +1,36 @@ +from test_support import verify +import pprint + +# Verify that .isrecursive() and .isreadable() work. + +a = range(100) +b = range(200) +a[-12] = b + +for safe in 2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, u"yaddayadda", a, b: + verify(pprint.isrecursive(safe) == 0, "expected isrecursive == 0") + verify(pprint.isreadable(safe) == 1, "expected isreadable == 1") + +# Tie a knot. +b[67] = a +# Messy dict. +d = {} +d[0] = d[1] = d[2] = d + +for icky in a, b, d, (d, d): + verify(pprint.isrecursive(icky) == 1, "expected isrecursive == 1") + verify(pprint.isreadable(icky) == 0, "expected isreadable == 0") + +# Break the cycles. +d.clear() +del a[:] +del b[:] + +for safe in a, b, d, (d, d): + verify(pprint.isrecursive(safe) == 0, "expected isrecursive == 0") + verify(pprint.isreadable(safe) == 1, "expected isreadable == 1") + +# Not recursive but not readable anyway. +for unreadable in type(3), pprint, pprint.isrecursive: + verify(pprint.isrecursive(unreadable) == 0, "expected isrecursive == 0") + verify(pprint.isreadable(unreadable) ==0, "expected isreadable == 0") |