mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 17:09:59 +03:00
CharField: Cover handling of surrogate characters
This commit is contained in:
parent
4607c8a866
commit
2a3d3550aa
|
@ -759,6 +759,21 @@ class TestCharField(FieldValues):
|
||||||
'Null characters are not allowed.'
|
'Null characters are not allowed.'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def test_surrogate_characters(self):
|
||||||
|
field = serializers.CharField()
|
||||||
|
|
||||||
|
for code_point, expected_message in (
|
||||||
|
(0xD800, 'Surrogate characters are not allowed: U+D800.'),
|
||||||
|
(0xDFFF, 'Surrogate characters are not allowed: U+DFFF.'),
|
||||||
|
):
|
||||||
|
with pytest.raises(serializers.ValidationError) as exc_info:
|
||||||
|
field.run_validation(chr(code_point))
|
||||||
|
assert exc_info.value.detail[0].code == 'surrogate_characters_not_allowed'
|
||||||
|
assert str(exc_info.value.detail[0]) == expected_message
|
||||||
|
|
||||||
|
for code_point in (0xD800 - 1, 0xDFFF + 1):
|
||||||
|
field.run_validation(chr(code_point))
|
||||||
|
|
||||||
def test_iterable_validators(self):
|
def test_iterable_validators(self):
|
||||||
"""
|
"""
|
||||||
Ensure `validators` parameter is compatible with reasonable iterables.
|
Ensure `validators` parameter is compatible with reasonable iterables.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user