mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Patch #542569: tp_print tp_repr tp_str in test_bool.py.
This commit is contained in:
parent
06a83e90aa
commit
2f6d4da278
1 changed files with 18 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
# 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:
|
||||||
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")
|
||||||
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue