Esempio n. 1
0
 def test_invalid_email(self):
     invalid1 = "user@example"
     assert_raises(ValueError, lambda: types.email(invalid1))
     invalid2 = "example.com"
     assert_raises(ValueError, lambda: types.email(invalid2))
     invalid3 = "user"
     assert_raises(ValueError, lambda: types.email(invalid3))
Esempio n. 2
0
 def output(self, key, obj):
     value = self.get_value(key, obj)
     if value is None:
         return self.default
     try:
         return types.email(value)
     except Exception as err:
         raise MarshallingError(err)