Esempio n. 1
0
    def __init__( self, clazz, name ):
        type_isinstance( PepTypeMatcher, clazz )
        type_is(         str,            name )

        PepValue.__init__( self )
        self.clazz = clazz
        self.name = name
        self.namespace = self.clazz.runtime_namespace( self, False )
Esempio n. 2
0
def Does_nothing_on_instance_of_subsubclass__test():
    type_isinstance(B, sobsob)
Esempio n. 3
0
def Throws_when_primitive_type_does_not_match__test():
    with assert_raises(AssertionError) as cm:
        type_isinstance(int, "foo")
    assert_regexp_matches(str(cm.exception), "^type_isinstance check failed")
    assert_regexp_matches(str(cm.exception), "int but found")
    assert_regexp_matches(str(cm.exception), "str.$")
Esempio n. 4
0
def Throws_when_class_does_not_match__test():
    with assert_raises(AssertionError) as cm:
        type_isinstance(B, a)
    assert_regexp_matches(str(cm.exception), "^type_isinstance check failed")
    assert_regexp_matches(str(cm.exception), "B but found")
    assert_regexp_matches(str(cm.exception), "A.$")
Esempio n. 5
0
def Does_nothing_when_primitive_type_matches__test():
    type_isinstance(int, 3)
Esempio n. 6
0
def Does_nothing_when_class_matches__test():
    type_isinstance(A, a)
Esempio n. 7
0
def Fails_when_first_arg_is_not_a_type_but_an_instance__test():
    with assert_raises(AssertionError):
        type_isinstance(a, a)
Esempio n. 8
0
def Fails_when_first_arg_is_not_a_type_but_an_int__test():
    with assert_raises(AssertionError) as cm:
        type_isinstance(3, a)
    assert_regexp_matches(str(cm.exception), "^Wrong arguments")