blob: 610e989e516aaba842cdbb9af4e8b11250db4757 [file] [log] [blame]
Tim Petersa814db52001-05-14 07:05:58 +00001from test_support import verify
2import pprint
3
4# Verify that .isrecursive() and .isreadable() work.
5
6a = range(100)
7b = range(200)
8a[-12] = b
9
10for safe in 2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, u"yaddayadda", a, b:
11 verify(pprint.isrecursive(safe) == 0, "expected isrecursive == 0")
12 verify(pprint.isreadable(safe) == 1, "expected isreadable == 1")
13
14# Tie a knot.
15b[67] = a
16# Messy dict.
17d = {}
18d[0] = d[1] = d[2] = d
19
20for icky in a, b, d, (d, d):
21 verify(pprint.isrecursive(icky) == 1, "expected isrecursive == 1")
22 verify(pprint.isreadable(icky) == 0, "expected isreadable == 0")
23
24# Break the cycles.
25d.clear()
26del a[:]
27del b[:]
28
29for safe in a, b, d, (d, d):
30 verify(pprint.isrecursive(safe) == 0, "expected isrecursive == 0")
31 verify(pprint.isreadable(safe) == 1, "expected isreadable == 1")
32
33# Not recursive but not readable anyway.
34for unreadable in type(3), pprint, pprint.isrecursive:
35 verify(pprint.isrecursive(unreadable) == 0, "expected isrecursive == 0")
36 verify(pprint.isreadable(unreadable) ==0, "expected isreadable == 0")