def test_source_vaa_scheme(): class MarshMallowScheme(marshmallow.Schema): x = marshmallow.fields.Str() @deal.pre(vaa.marshmallow(MarshMallowScheme)) def identity(x): return x with pytest.raises(deal.ContractError) as exc_info: identity(-2) assert exc_info.value.source.startswith( '<vaa._external.Marshmallow object at ') exp = "[Error(message='Not a valid string.', field='x')] (where x=-2)" state.color = False assert str(exc_info.value) == exp state.color = True
def setUp(self): class _Scheme(marshmallow.Schema): name = marshmallow.fields.Str() self.Scheme = vaa.marshmallow(_Scheme)
import marshmallow import pyschemes import vaa class PostMarshmallow(marshmallow.Schema): name = marshmallow.fields.Str(required=True) mail = marshmallow.fields.Email(required=True) count = marshmallow.fields.Int(required=True) post_pyschemes = pyschemes.Scheme({ 'name': str, 'mail': str, 'count': int, }) postmodels = [ PostMarshmallow, post_pyschemes, ] postvalidators = [ vaa.marshmallow(PostMarshmallow), vaa.pyschemes(post_pyschemes), ]