def assert_raises(matcher=None, message=""): # Short hand for instance_of matcher if is_matchable_type(matcher): matcher = instance_of(matcher) else: matcher = wrap_matcher(matcher) context = RaisesContext() try: yield context except Exception as e: context.exception = e assert_that(context.exception, matcher, message)
def assert_raises(matcher=None, message=''): # Short hand for instance_of matcher if is_matchable_type(matcher): matcher = instance_of(matcher) else: matcher = wrap_matcher(matcher) context = RaisesContext() try: yield context except Exception as e: context.exception = e assert_that(context.exception, matcher, message)
def wrap_value_or_type(x): if is_matchable_type(x): return instance_of(x) else: return wrap_matcher(x)
def __init__(self, expected_type): if not is_matchable_type(expected_type): raise TypeError('IsInstanceOf requires type') self.expected_type = expected_type
def __init__(self, expected_type: Type) -> None: if not is_matchable_type(expected_type): raise TypeError("IsInstanceOf requires type") self.expected_type = expected_type
def __init__(self, expected_type): if not is_matchable_type(expected_type): raise TypeError('IsInstanceOf requires type or a tuple of classes and types') self.expected_type = expected_type
def __init__(self, expected_type): if not is_matchable_type(expected_type): raise TypeError( 'IsInstanceOf requires type or a tuple of classes and types') self.expected_type = expected_type