def test_invalid_email(self): invalid1 = "user@example" assert_raises(ValueError, lambda: validate.email(invalid1)) invalid2 = "example.com" assert_raises(ValueError, lambda: validate.email(invalid2)) invalid3 = "user" assert_raises(ValueError, lambda: validate.email(invalid3))
def test_invalid_email(): invalid1 = "user@example" with pytest.raises(ValidationError): validate.email(invalid1) invalid2 = "example.com" with pytest.raises(ValidationError): validate.email(invalid2) invalid3 = "user" with pytest.raises(ValidationError): validate.email(invalid3) with pytest.raises(ValidationError): validate.email('@nouser.com')
def test_invalid_email(self): invalid1 = "user@example" with pytest.raises(ValueError): validate.email(invalid1) invalid2 = "example.com" with pytest.raises(ValueError): validate.email(invalid2) invalid3 = "user" with pytest.raises(ValueError): validate.email(invalid3)
def test_validate_email_none(): assert validate.email(None) is None
def output(self, key, obj): value = self.get_value(key, obj) if value is None: return self.default return validate.email(value)
def _validated(self, value): return validate.email(value, error=getattr(self, 'error'))