for self-test: handle TypeErrors nicely

master
lars 15 years ago
parent 43a5c83ea8
commit 81e5a2e8fd
  1. 16
      src/cryptobox/core/blockdevice.py

@ -741,8 +741,12 @@ class Blockdevice:
output += "\tflags:\t\t"
for funcname in [ func for func in dir(self)
if func.startswith("is_") and callable(getattr(self, func))]:
if getattr(self, funcname)():
output += "%s " % funcname[3:]
try:
if getattr(self, funcname)():
output += "%s " % funcname[3:]
except TypeError:
# skip tests that need arguments (e.g. "is_parent_of")
pass
output += "\n"
return output
@ -1003,7 +1007,11 @@ if __name__ == '__main__':
for check in flag_checker:
show("List of '%s' devices:" % check[3:])
for device in blocks:
if getattr(device, check)():
show("\t%s" % device)
try:
if getattr(device, check)():
show("\t%s" % device)
except TypeError:
# ignore tests that need a second argument
pass
show()

Loading…
Cancel
Save