Add python AttributeError test for non-existent attribute
This commit is contained in:
parent
de4b3a4a59
commit
333a46f07d
1 changed files with 10 additions and 0 deletions
|
|
@ -71,3 +71,13 @@ if myStringyClass.ReadWriteString != "changed string":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if myStringyClass.ReadOnlyString != "changed string":
|
if myStringyClass.ReadOnlyString != "changed string":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
# Check a proper AttributeError is raised for non-existent attributes, old versions used to raise unhelpful error:
|
||||||
|
# AttributeError: type object 'object' has no attribute '__getattr__'
|
||||||
|
try:
|
||||||
|
x = myFoo.does_not_exist
|
||||||
|
raise RuntimeError
|
||||||
|
except AttributeError, e:
|
||||||
|
if str(e).find("does_not_exist") == -1:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue