mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
Fixes #3265 (now with Test Case)
- Added test_data_access_before_save_raises_error test
This commit is contained in:
parent
41b796d844
commit
134f5fa4bc
|
@ -51,6 +51,15 @@ class TestSerializer:
|
|||
with pytest.raises(AttributeError):
|
||||
serializer.data
|
||||
|
||||
def test_data_access_before_save_raises_error(self):
|
||||
def create(validated_data):
|
||||
return validated_data
|
||||
serializer = self.Serializer(data={'char': 'abc', 'integer': 123})
|
||||
serializer.create = create
|
||||
assert serializer.is_valid()
|
||||
assert serializer.data == {'char': 'abc', 'integer': 123}
|
||||
with pytest.raises(AssertionError):
|
||||
serializer.save()
|
||||
|
||||
class TestValidateMethod:
|
||||
def test_non_field_error_validate_method(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user