Skip to content

Commit

Permalink
Merge pull request analogdevicesinc#482 from analogdevicesinc/dlech/f…
Browse files Browse the repository at this point in the history
…ix-attr-tests
  • Loading branch information
tfcollins authored Oct 5, 2023
2 parents 301a5f5 + fa0404f commit 93ce4fe
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/attr_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def attribute_single_value_boolean(uri, classname, attr, value):
Value to write and read back from attribute
"""
bi = eval(classname + "(uri='" + uri + "')")

if not hasattr(bi, attr):
raise AttributeError(f"no attribute named: {attr}")

setattr(bi, attr, value)
rval = getattr(bi, attr)
del bi
Expand Down Expand Up @@ -258,6 +262,10 @@ def attribute_write_only_str(uri, classname, attr, value):
Value to write into attr property
"""
sdr = eval(classname + "(uri='" + uri + "')")

if not hasattr(sdr, attr):
raise AttributeError(f"no attribute named: {attr}")

try:
setattr(sdr, attr, value)
del sdr
Expand All @@ -284,6 +292,14 @@ def attribute_write_only_str_with_depends(uri, classname, attr, value, depends):
are properties and values are values to be written
"""
sdr = eval(classname + "(uri='" + uri + "')")

for p in depends:
if not hasattr(sdr, p):
raise AttributeError(f"no attribute named: {p}")

if not hasattr(sdr, attr):
raise AttributeError(f"no attribute named: {attr}")

for p in depends:
setattr(sdr, p, depends[p])
try:
Expand Down

0 comments on commit 93ce4fe

Please sign in to comment.