mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Add tests for getattr() and hasattr() with non-string args
This commit is contained in:
parent
302b54acd9
commit
b7a7731e01
2 changed files with 24 additions and 0 deletions
|
@ -205,6 +205,12 @@ print 'setattr'
|
|||
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(\'\')'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue