Exemple #1
0
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)
Exemple #2
0
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)
Exemple #3
0
def wrap_value_or_type(x):
    if is_matchable_type(x):
        return instance_of(x)
    else:
        return wrap_matcher(x)
Exemple #4
0
 def __init__(self, expected_type):
     if not is_matchable_type(expected_type):
         raise TypeError('IsInstanceOf requires type')
     self.expected_type = expected_type
Exemple #5
0
 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
Exemple #7
0
 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