cfme.utils.error module¶
Handles errors based on something beyond the type. You can match error messages with regular expressions. You can also extend the matching behavior however you like. By default, strings are treated as regex and matched against the message of the error. Functions are passed the error and if the function returns ‘truthy’, then the error is caught.
Usage:
from cfme.utils import error
with error.expected('foo'):
x = 1
raise Exception('oh noes foo happened!') # this will be caught because regex matches
with error.expected('foo'):
raise Exception('oh noes bar happened!') # this will bubble up because it doesn't match
with error.expected('foo'):
pass # an error will be thrown because we expected an error but there wasn't one.
-
exception
cfme.utils.error.
UnexpectedSuccessException
[source]¶ Bases:
exceptions.Exception
An error that is thrown when something we expected to fail didn’t fail.
-
cfme.utils.error.
expected
(*args, **kwds)[source]¶ Inverts error handling. If the enclosed block doesn’t raise an error, it will raise one. If it raises a matching error, it will return normally. If it raises a non-matching error, that error will be allowed to propagate up the stack.