-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepend field name to ValidationError messages
- Loading branch information
Showing
3 changed files
with
17 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ def test_when_validate_and_validation_errors_then_raises_first_validation_error( | |
user = UserWithRequiredName(email='[email protected]') | ||
|
||
expect(lambda: user.validate()).to(raise_error( | ||
errors.ValidationError, 'is required')) | ||
errors.ValidationError, 'name is required')) | ||
|
||
def test_when_validate_without_errors_then_does_not_raise(self): | ||
user = UserWithRequiredName(name='Jack') | ||
|
@@ -85,6 +85,12 @@ def test_when_validation_errors_and_no_errors_then_returns_none(self): | |
|
||
expect(errors).to(be_empty) | ||
|
||
def test_exceptions_contain_field_names(self): | ||
user = UserWithRequiredName() | ||
|
||
expect(user.validate).to(raise_error(errors.ValidationError, | ||
'name is required')) | ||
|
||
|
||
class TestInheritedModel(object): | ||
def test_when_pass_kwargs_then_set_fields_values(self): | ||
|
@@ -123,7 +129,7 @@ class User(UserMixin, models.Model): | |
user = User() | ||
|
||
expect(lambda: user.validate()).to(raise_error( | ||
errors.ValidationError, 'is required')) | ||
errors.ValidationError, 'name is required')) | ||
|
||
|
||
class TestDictModel(object): | ||
|