mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 13:54:47 +03:00
Merge a2898d71c0
into 7f29cfc931
This commit is contained in:
commit
ae544d6d76
|
@ -62,6 +62,19 @@ class TestSerializer:
|
||||||
with pytest.raises(AssertionError):
|
with pytest.raises(AssertionError):
|
||||||
serializer.save()
|
serializer.save()
|
||||||
|
|
||||||
|
def test_non_validation_error_escapes(self):
|
||||||
|
from rest_framework.exceptions import APIException
|
||||||
|
|
||||||
|
class CustomException(APIException):
|
||||||
|
@classmethod
|
||||||
|
def throw(self, *a, **kw):
|
||||||
|
raise self
|
||||||
|
|
||||||
|
serializer = self.Serializer(data={'char': 'abc', 'integer': 123})
|
||||||
|
serializer.validate_char = CustomException.throw
|
||||||
|
with pytest.raises(CustomException):
|
||||||
|
serializer.is_valid()
|
||||||
|
|
||||||
|
|
||||||
class TestValidateMethod:
|
class TestValidateMethod:
|
||||||
def test_non_field_error_validate_method(self):
|
def test_non_field_error_validate_method(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user