def test_validate_layered_boxed_types(fx_layered_boxed_types): A, B, C = fx_layered_boxed_types assert validate_unboxed_type(u'test', text_type) assert validate_unboxed_type(A(u'test'), A) assert validate_unboxed_type(B(A(u'test')), B) with raises(TypeError): assert validate_unboxed_type(u'test', A) with raises(TypeError): assert validate_unboxed_type(u'test', B) with raises(TypeError): assert validate_unboxed_type(A(u'test'), B)
def test_validate_unboxed_type(): assert validate_unboxed_type(3.14, float) with raises(TypeError): validate_unboxed_type(u'hello', float)
def __init__(self, value): validate_unboxed_type(value, B) self.value = value # type: B
def __init__(self, value): validate_unboxed_type(value, uuid.UUID) self.value = value
def __init__(self, value): validate_unboxed_type(value, text_type) self.value = value # type: Text