Kaydet (Commit) 2f6d4da2 authored tarafından Martin v. Löwis's avatar Martin v. Löwis

Patch #542569: tp_print tp_repr tp_str in test_bool.py.

üst 06a83e90
# Test properties of bool promised by PEP 285 # Test properties of bool promised by PEP 285
from test_support import verbose, TestFailed, TESTFN, vereq from test_support import verbose, TestFailed, TESTFN, vereq
import os
def veris(a, b): def veris(a, b):
if a is not b: if a is not b:
...@@ -25,6 +26,23 @@ except TypeError: ...@@ -25,6 +26,23 @@ except TypeError:
else: else:
raise TestFailed, "should not be able to create new bool instances" 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) vereq(int(False), 0)
verisnot(int(False), False) verisnot(int(False), False)
vereq(int(True), 1) vereq(int(True), 1)
...@@ -185,7 +203,6 @@ f = file(TESTFN, "w") ...@@ -185,7 +203,6 @@ f = file(TESTFN, "w")
veris(f.closed, False) veris(f.closed, False)
f.close() f.close()
veris(f.closed, True) veris(f.closed, True)
import os
os.remove(TESTFN) os.remove(TESTFN)
import operator import operator
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment