From 81e5a2e8fd145f0c59a07fb049b6bbf0e7ec14a3 Mon Sep 17 00:00:00 2001 From: lars Date: Mon, 7 Apr 2008 02:57:33 +0000 Subject: [PATCH] for self-test: handle TypeErrors nicely --- src/cryptobox/core/blockdevice.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cryptobox/core/blockdevice.py b/src/cryptobox/core/blockdevice.py index 4dc20e1..01561e0 100644 --- a/src/cryptobox/core/blockdevice.py +++ b/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()