def who_can(self, what, expected = [], extra_khs = []):
for kh in list(range(<NUM_LIT:1>, <NUM_LIT:32>)) + extra_khs:<EOL><INDENT>if kh in expected:<EOL><INDENT>continue<EOL><DEDENT>res = None<EOL>try:<EOL><INDENT>res = what(kh)<EOL>self.fail("<STR_LIT>" % (kh, res))<EOL><DEDENT>except pyhsm.exception.YHSM_CommandFailed as e:<EOL><INDENT>if e.status != pyhsm.defines.YSM_FUNCTION_DISABLED:<EOL><INDENT>self.fail("<STR_LIT>"% (kh, e.status_str))<EOL><DEDENT><DEDENT><DEDENT>
Try the lambda what() with all key handles between 1 and 32, except the expected one.
Fail on anything but YSM_FUNCTION_DISABLED.