summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2002-04-14 10:22:29 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2002-04-14 10:22:29 (GMT)
commit2f6d4da2784c79bfc8f3c38fda1ac4c95f6a3b11 (patch)
tree838bf84bdeb3bb81c4a4755f9599ace1682a4f92 /Lib/test
parent06a83e90aa345c27db2652ddccdba683cdfa9311 (diff)
downloadcpython-2f6d4da2784c79bfc8f3c38fda1ac4c95f6a3b11.zip
cpython-2f6d4da2784c79bfc8f3c38fda1ac4c95f6a3b11.tar.gz
cpython-2f6d4da2784c79bfc8f3c38fda1ac4c95f6a3b11.tar.bz2
Patch #542569: tp_print tp_repr tp_str in test_bool.py.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_bool.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_bool.py b/Lib/test/test_bool.py
index 388cd4b..f5c91d5 100644
--- a/Lib/test/test_bool.py
+++ b/Lib/test/test_bool.py
@@ -1,6 +1,7 @@
# Test properties of bool promised by PEP 285
from test_support import verbose, TestFailed, TESTFN, vereq
+import os
def veris(a, b):
if a is not b:
@@ -25,6 +26,23 @@ except TypeError:
else:
raise TestFailed, "should not be able to create new bool instances"
+# checking tp_print slot
+fo = open(TESTFN, "wb")
+print >> fo, False, True
+fo.close()
+fo = open(TESTFN, "rb")
+vereq(fo.read(), 'False True\n')
+fo.close()
+os.remove(TESTFN)
+
+# checking repr and str
+vereq(str(False), 'False')
+vereq(str(True), 'True')
+vereq(repr(False), 'False')
+vereq(repr(True), 'True')
+vereq(eval(repr(False)), False)
+vereq(eval(repr(True)), True)
+
vereq(int(False), 0)
verisnot(int(False), False)
vereq(int(True), 1)
@@ -185,7 +203,6 @@ f = file(TESTFN, "w")
veris(f.closed, False)
f.close()
veris(f.closed, True)
-import os
os.remove(TESTFN)
import operator