[Python-checkins] python/dist/src/Lib/test test_types.py,1.48,1.49 test_bool.py,1.7,1.8
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Sat, 19 Apr 2003 11:15:12 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv15651/Lib/test
Modified Files:
test_types.py test_bool.py
Log Message:
- bool() called without arguments now returns False rather than
raising an exception. This is consistent with calling the
constructors for the other builtin types -- called without argument
they all return the false value of that type. (SF patch #724135)
Thanks to Alex Martelli.
Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** test_types.py 14 Apr 2003 20:58:03 -0000 1.48
--- test_types.py 19 Apr 2003 18:15:07 -0000 1.49
***************
*** 87,90 ****
--- 87,94 ----
if -1 != -1L or -1 != -1.0 or -1L != -1.0:
raise TestFailed, 'int/long/float value not equal'
+ # calling built-in types without argument must return 0
+ if int() != 0: raise TestFailed, 'int() does not return 0'
+ if long() != 0L: raise TestFailed, 'long() does not return 0L'
+ if float() != 0.0: raise TestFailed, 'float() does not return 0.0'
if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass
else: raise TestFailed, 'int() does not round properly'
***************
*** 215,218 ****
--- 219,224 ----
print '6.5.2 Tuples'
+ # calling built-in types without argument must return empty
+ if tuple() != (): raise TestFailed,'tuple() does not return ()'
if len(()) != 0: raise TestFailed, 'len(())'
if len((1,)) != 1: raise TestFailed, 'len((1,))'
***************
*** 252,255 ****
--- 258,263 ----
print '6.5.3 Lists'
+ # calling built-in types without argument must return empty
+ if list() != []: raise TestFailed,'list() does not return []'
if len([]) != 0: raise TestFailed, 'len([])'
if len([1,]) != 1: raise TestFailed, 'len([1,])'
***************
*** 442,445 ****
--- 450,455 ----
print '6.6 Mappings == Dictionaries'
+ # calling built-in types without argument must return empty
+ if dict() != {}: raise TestFailed,'dict() does not return {}'
d = {}
if d.keys() != []: raise TestFailed, '{}.keys()'
Index: test_bool.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_bool.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** test_bool.py 23 Jul 2002 19:03:45 -0000 1.7
--- test_bool.py 19 Apr 2003 18:15:09 -0000 1.8
***************
*** 138,141 ****
--- 138,142 ----
veris(bool("hello"), True)
veris(bool(""), False)
+ veris(bool(), False)
veris(hasattr([], "append"), True)