[Python-checkins] CVS: python/dist/src/Lib/test test_b1.py,1.36,1.37 test_b2.py,1.26,1.27
Jeremy Hylton
jhylton@users.sourceforge.net
Mon, 30 Jul 2001 15:49:13 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv30218/Lib/test
Modified Files:
test_b1.py test_b2.py
Log Message:
Add tests for getattr() and hasattr() with non-string args
Index: test_b1.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b1.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** test_b1.py 2001/07/26 20:02:17 1.36
--- test_b1.py 2001/07/30 22:49:11 1.37
***************
*** 257,264 ****
--- 257,282 ----
import sys
if getattr(sys, 'stdout') is not sys.stdout: raise TestFailed, 'getattr'
+ try:
+ getattr(sys, 1)
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "getattr(sys, 1) should raise an exception"
+ try:
+ getattr(sys, 1, "foo")
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, 'getattr(sys, 1, "foo") should raise an exception'
print 'hasattr'
import sys
if not hasattr(sys, 'stdout'): raise TestFailed, 'hasattr'
+ try:
+ hasattr(sys, 1)
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "hasattr(sys, 1) should raise an exception"
print 'hash'
Index: test_b2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_b2.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** test_b2.py 2001/07/05 14:49:21 1.26
--- test_b2.py 2001/07/30 22:49:11 1.27
***************
*** 206,209 ****
--- 206,215 ----
setattr(sys, 'spam', 1)
if sys.spam != 1: raise TestFailed, 'setattr(sys, \'spam\', 1)'
+ try:
+ setattr(sys, 1, 'spam')
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "setattr(sys, 1, 'spam') should raise exception"
print 'str'