[kms-test] [PATCH 9/7] kmstest: Raise clear exception when property is not found

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When converting a property value string to an integer, if the property
is not found, an AttributeError exception is raised and reports that
"'NoneType' object has no attribute 'type'". This isn't very clear,
replace it with a RuntimeError with a proper message.

Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
---
 tests/kmstest.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/kmstest.py b/tests/kmstest.py
index e84d8fe859f4..3e53defc1dae 100755
--- a/tests/kmstest.py
+++ b/tests/kmstest.py
@@ -268,6 +268,8 @@ class AtomicRequest(pykms.AtomicReq):
             if isinstance(v, str):
                 if v.endswith('%'):
                     prop = obj.get_prop(k)
+                    if not prop:
+                        raise RuntimeError(f'Property {k} not supported by object {obj}')
                     if prop.type not in (pykms.PropertyType.Range, pykms.PropertyType.SignedRange):
                         raise RuntimeError(f'Unsupported property type {prop.type} for value {v}')
 
-- 
Regards,

Laurent Pinchart




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux