annotate Lib/test/test_bool.py @ 27998:e27f58a50737 legacy-trunk

SF bug #690377: Dud footnote reference in distutils docs
author Raymond Hettinger <python@rcn.com>
date Fri, 21 Feb 2003 02:47:09 +0000
parents aa0d2d51fbde
children 658b10c5ba2a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # Test properties of bool promised by PEP 285
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
24364
aa0d2d51fbde Get rid of relative imports in all unittests. Now anything that
Barry Warsaw <barry@python.org>
parents: 23778
diff changeset
3 from test.test_support import verbose, TestFailed, TESTFN, vereq, have_unicode
23027
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
4 import os
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 def veris(a, b):
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 if a is not b:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 raise TestFailed, "%r is %r" % (a, b)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 def verisnot(a, b):
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 if a is b:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 raise TestFailed, "%r is %r" % (a, b)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 try:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 class C(bool):
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 pass
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 except TypeError:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 pass
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 else:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 raise TestFailed, "bool should not be subclassable"
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 try:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 int.__new__(bool, 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 except TypeError:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 pass
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 else:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 raise TestFailed, "should not be able to create new bool instances"
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28
23027
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
29 # checking tp_print slot
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
30 fo = open(TESTFN, "wb")
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
31 print >> fo, False, True
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
32 fo.close()
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
33 fo = open(TESTFN, "rb")
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
34 vereq(fo.read(), 'False True\n')
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
35 fo.close()
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
36 os.remove(TESTFN)
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
37
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
38 # checking repr and str
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
39 vereq(str(False), 'False')
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
40 vereq(str(True), 'True')
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
41 vereq(repr(False), 'False')
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
42 vereq(repr(True), 'True')
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
43 vereq(eval(repr(False)), False)
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
44 vereq(eval(repr(True)), True)
03c39640d81a Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 22853
diff changeset
45
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 vereq(int(False), 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 verisnot(int(False), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 vereq(int(True), 1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 verisnot(int(True), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
50
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 vereq(+False, 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 verisnot(+False, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 vereq(-False, 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 verisnot(-False, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 vereq(abs(False), 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 verisnot(abs(False), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 vereq(+True, 1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 verisnot(+True, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 vereq(-True, -1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 vereq(abs(True), 1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 verisnot(abs(True), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 vereq(~False, -1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 vereq(~True, -2)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
64
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 vereq(False+2, 2)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 vereq(True+2, 3)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 vereq(2+False, 2)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 vereq(2+True, 3)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
69
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 vereq(False+False, 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 verisnot(False+False, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 vereq(False+True, 1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 verisnot(False+True, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 vereq(True+False, 1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 verisnot(True+False, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 vereq(True+True, 2)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
77
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 vereq(True-True, 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 verisnot(True-True, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 vereq(False-False, 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 verisnot(False-False, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 vereq(True-False, 1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 verisnot(True-False, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
84 vereq(False-True, -1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
85
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 vereq(True*1, 1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
87 vereq(False*1, 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
88 verisnot(False*1, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
89
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 vereq(True/1, 1)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 verisnot(True/1, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 vereq(False/1, 0)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 verisnot(False/1, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
94
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
95 for b in False, True:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
96 for i in 0, 1, 2:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
97 vereq(b**i, int(b)**i)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
98 verisnot(b**i, bool(int(b)**i))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
99
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
100 for a in False, True:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
101 for b in False, True:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 veris(a&b, bool(int(a)&int(b)))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
103 veris(a|b, bool(int(a)|int(b)))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
104 veris(a^b, bool(int(a)^int(b)))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 vereq(a&int(b), int(a)&int(b))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 verisnot(a&int(b), bool(int(a)&int(b)))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 vereq(a|int(b), int(a)|int(b))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
108 verisnot(a|int(b), bool(int(a)|int(b)))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
109 vereq(a^int(b), int(a)^int(b))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
110 verisnot(a^int(b), bool(int(a)^int(b)))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
111 vereq(int(a)&b, int(a)&int(b))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
112 verisnot(int(a)&b, bool(int(a)&int(b)))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
113 vereq(int(a)|b, int(a)|int(b))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
114 verisnot(int(a)|b, bool(int(a)|int(b)))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
115 vereq(int(a)^b, int(a)^int(b))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
116 verisnot(int(a)^b, bool(int(a)^int(b)))
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
117
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 veris(1==1, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
119 veris(1==0, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
120 # XXX <, <=, >, >=, !=
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
121
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
122 x = [1]
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
123 veris(x is x, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
124 veris(x is not x, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
125
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
126 veris(1 in x, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
127 veris(0 in x, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
128 veris(1 not in x, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
129 veris(0 not in x, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
130
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
131 veris(not True, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
132 veris(not False, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
133
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
134 veris(bool(10), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
135 veris(bool(1), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
136 veris(bool(-1), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
137 veris(bool(0), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
138 veris(bool("hello"), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
139 veris(bool(""), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
140
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
141 veris(hasattr([], "append"), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
142 veris(hasattr([], "wobble"), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
143
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
144 veris(callable(len), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
145 veris(callable(1), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
146
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
147 veris(isinstance(True, bool), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
148 veris(isinstance(False, bool), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
149 veris(isinstance(True, int), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
150 veris(isinstance(False, int), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
151 veris(isinstance(1, bool), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
152 veris(isinstance(0, bool), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
153
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
154 veris(issubclass(bool, int), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
155 veris(issubclass(int, bool), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
156
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
157 veris({}.has_key(1), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
158 veris({1:1}.has_key(1), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
159
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
160 veris("xyz".endswith("z"), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
161 veris("xyz".endswith("x"), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
162 veris("xyz0123".isalnum(), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
163 veris("@#$%".isalnum(), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
164 veris("xyz".isalpha(), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
165 veris("@#$%".isalpha(), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
166 veris("0123".isdigit(), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
167 veris("xyz".isdigit(), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
168 veris("xyz".islower(), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
169 veris("XYZ".islower(), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
170 veris(" ".isspace(), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
171 veris("XYZ".isspace(), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
172 veris("X".istitle(), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
173 veris("x".istitle(), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
174 veris("XYZ".isupper(), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
175 veris("xyz".isupper(), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
176 veris("xyz".startswith("x"), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
177 veris("xyz".startswith("z"), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
178
23481
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
179 if have_unicode:
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
180 veris(unicode("xyz", 'ascii').endswith(unicode("z", 'ascii')), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
181 veris(unicode("xyz", 'ascii').endswith(unicode("x", 'ascii')), False)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
182 veris(unicode("xyz0123", 'ascii').isalnum(), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
183 veris(unicode("@#$%", 'ascii').isalnum(), False)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
184 veris(unicode("xyz", 'ascii').isalpha(), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
185 veris(unicode("@#$%", 'ascii').isalpha(), False)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
186 veris(unicode("0123", 'ascii').isdecimal(), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
187 veris(unicode("xyz", 'ascii').isdecimal(), False)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
188 veris(unicode("0123", 'ascii').isdigit(), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
189 veris(unicode("xyz", 'ascii').isdigit(), False)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
190 veris(unicode("xyz", 'ascii').islower(), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
191 veris(unicode("XYZ", 'ascii').islower(), False)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
192 veris(unicode("0123", 'ascii').isnumeric(), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
193 veris(unicode("xyz", 'ascii').isnumeric(), False)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
194 veris(unicode(" ", 'ascii').isspace(), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
195 veris(unicode("XYZ", 'ascii').isspace(), False)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
196 veris(unicode("X", 'ascii').istitle(), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
197 veris(unicode("x", 'ascii').istitle(), False)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
198 veris(unicode("XYZ", 'ascii').isupper(), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
199 veris(unicode("xyz", 'ascii').isupper(), False)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
200 veris(unicode("xyz", 'ascii').startswith(unicode("x", 'ascii')), True)
d917857fd334 More mindless --disable-unicode proofing.
Michael W. Hudson <mwh@python.net>
parents: 23027
diff changeset
201 veris(unicode("xyz", 'ascii').startswith(unicode("z", 'ascii')), False)
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
202
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
203 f = file(TESTFN, "w")
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
204 veris(f.closed, False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
205 f.close()
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
206 veris(f.closed, True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
207 os.remove(TESTFN)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
208
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
209 import operator
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
210 veris(operator.truth(0), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
211 veris(operator.truth(1), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
212 veris(operator.isCallable(0), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
213 veris(operator.isCallable(len), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
214 veris(operator.isNumberType(None), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
215 veris(operator.isNumberType(0), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
216 veris(operator.not_(1), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
217 veris(operator.not_(0), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
218 veris(operator.isSequenceType(0), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
219 veris(operator.isSequenceType([]), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
220 veris(operator.contains([], 1), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
221 veris(operator.contains([1], 1), True)
23778
245224d1b8c9 This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents: 23481
diff changeset
222 veris(operator.isMappingType(1), False)
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
223 veris(operator.isMappingType({}), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
224 veris(operator.lt(0, 0), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
225 veris(operator.lt(0, 1), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
226
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
227 import marshal
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
228 veris(marshal.loads(marshal.dumps(True)), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
229 veris(marshal.loads(marshal.dumps(False)), False)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
230
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
231 import pickle
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
232 veris(pickle.loads(pickle.dumps(True)), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
233 veris(pickle.loads(pickle.dumps(False)), False)
22853
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
234 veris(pickle.loads(pickle.dumps(True, True)), True)
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
235 veris(pickle.loads(pickle.dumps(False, True)), False)
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
236
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
237 import cPickle
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
238 veris(cPickle.loads(cPickle.dumps(True)), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
239 veris(cPickle.loads(cPickle.dumps(False)), False)
22853
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
240 veris(cPickle.loads(cPickle.dumps(True, True)), True)
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
241 veris(cPickle.loads(cPickle.dumps(False, True)), False)
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
242
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
243 veris(pickle.loads(cPickle.dumps(True)), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
244 veris(pickle.loads(cPickle.dumps(False)), False)
22853
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
245 veris(pickle.loads(cPickle.dumps(True, True)), True)
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
246 veris(pickle.loads(cPickle.dumps(False, True)), False)
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
247
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
248 veris(cPickle.loads(pickle.dumps(True)), True)
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
249 veris(cPickle.loads(pickle.dumps(False)), False)
22853
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
250 veris(cPickle.loads(pickle.dumps(True, True)), True)
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
251 veris(cPickle.loads(pickle.dumps(False, True)), False)
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
252
22851
ed03806d88cd Implement an idea by Paul Rubin:
Guido van Rossum <guido@python.org>
parents: 22787
diff changeset
253 # Test for specific backwards-compatible pickle values
ed03806d88cd Implement an idea by Paul Rubin:
Guido van Rossum <guido@python.org>
parents: 22787
diff changeset
254 vereq(pickle.dumps(True), "I01\n.")
ed03806d88cd Implement an idea by Paul Rubin:
Guido van Rossum <guido@python.org>
parents: 22787
diff changeset
255 vereq(pickle.dumps(False), "I00\n.")
ed03806d88cd Implement an idea by Paul Rubin:
Guido van Rossum <guido@python.org>
parents: 22787
diff changeset
256 vereq(cPickle.dumps(True), "I01\n.")
ed03806d88cd Implement an idea by Paul Rubin:
Guido van Rossum <guido@python.org>
parents: 22787
diff changeset
257 vereq(cPickle.dumps(False), "I00\n.")
22853
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
258 vereq(pickle.dumps(True, True), "I01\n.")
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
259 vereq(pickle.dumps(False, True), "I00\n.")
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
260 vereq(cPickle.dumps(True, True), "I01\n.")
188b0fa28007 Add tests for binary pickles.
Guido van Rossum <guido@python.org>
parents: 22851
diff changeset
261 vereq(cPickle.dumps(False, True), "I00\n.")
22851
ed03806d88cd Implement an idea by Paul Rubin:
Guido van Rossum <guido@python.org>
parents: 22787
diff changeset
262
22787
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
263 if verbose:
028ebc8fb390 Oops. Here are the new files. My apologies.
Guido van Rossum <guido@python.org>
parents:
diff changeset
264 print "All OK"