print 'getattr'
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'
hash(None)
import sys
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'
if str('') != '': raise TestFailed, 'str(\'\')'