def test_field_run_validators(self): field = Field('easy') obj = {'easy': 'test'} with patch.object(field, 'run_validators') as mock: field.get_value(obj) mock.assert_called_once_with(obj['easy'])
def test_raise_on_bad_delim(self): field = Field('test', delimiter=1) field.name = 'hello' self.assertRaisesRegexp( ImproperlyConfigured, ( 'Field attribute hello.delimiter expected a character ' 'buffer object' ), field.get_value, {} )
def test_field_raises_fielderror(self): field = Field('ha.nope') field.name = 'nope' obj = {'ha': 1} self.assertRaises(FieldError, field.get_value, obj) self.assertRaises(ParserError, field.get_value, obj) self.assertRaises(TypeError, field.get_value, obj)