Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f6d4da

Browse files
committed
Patch #542569: tp_print tp_repr tp_str in test_bool.py.
1 parent 06a83e9 commit 2f6d4da

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

Lib/test/test_bool.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Test properties of bool promised by PEP 285
22

33
from test_support import verbose, TestFailed, TESTFN, vereq
4+
import os
45

56
def veris(a, b):
67
if a is not b:
@@ -25,6 +26,23 @@ class C(bool):
2526
else:
2627
raise TestFailed, "should not be able to create new bool instances"
2728

29+
# checking tp_print slot
30+
fo = open(TESTFN, "wb")
31+
print >> fo, False, True
32+
fo.close()
33+
fo = open(TESTFN, "rb")
34+
vereq(fo.read(), 'False True\n')
35+
fo.close()
36+
os.remove(TESTFN)
37+
38+
# checking repr and str
39+
vereq(str(False), 'False')
40+
vereq(str(True), 'True')
41+
vereq(repr(False), 'False')
42+
vereq(repr(True), 'True')
43+
vereq(eval(repr(False)), False)
44+
vereq(eval(repr(True)), True)
45+
2846
vereq(int(False), 0)
2947
verisnot(int(False), False)
3048
vereq(int(True), 1)
@@ -185,7 +203,6 @@ class C(bool):
185203
veris(f.closed, False)
186204
f.close()
187205
veris(f.closed, True)
188-
import os
189206
os.remove(TESTFN)
190207

191208
import operator

0 commit comments

Comments
 (0)