async def test_validate__invalid(self): field = fields.String() with self.assertRaises(exceptions.ValidationError) as context: await field.validate(10) self.assertEqual(context.exception.error, fields.String.errors['invalid'])
async def test_validate__max_length(self): field = fields.String(max_length=3, default='test') with self.assertRaises(exceptions.ValidationError) as context: await field.validate(None) self.assertEqual(context.exception.error, fields.String.errors['max_length'].format(field))
async def test_validate(self): field = fields.String() self.assertEqual('Test', await field.validate('Test'))
async def test_serialize__none(self): field = fields.String() self.assertEqual(None, await field.serialize(None))