Fixed test_hyperlinked_related_lookup_url_encoded_exists. by felixxm · Pull Request #5179 · encode/django-rest-framework (original) (raw)
I fixed TestHyperlinkedRelatedField.test_hyperlinked_related_lookup_url_encoded_exists
on Django master:
TestHyperlinkedRelatedField.test_hyperlinked_related_lookup_url_encoded_exists rest_framework/relations.py:347: in to_internal_value return self.get_object(match.view_name, match.args, match.kwargs) rest_framework/relations.py:298: in get_object return self.get_queryset().get(**lookup_kwargs) tests/utils.py:30: in get raise ObjectDoesNotExist() E django.core.exceptions.ObjectDoesNotExist During handling of the above exception, another exception occurred: tests/test_relations.py:119: in test_hyperlinked_related_lookup_url_encoded_exists instance = self.field.to_internal_value('http://example.org/example/baz%20qux/') rest_framework/relations.py:349: in to_internal_value self.fail('does_not_exist') rest_framework/fields.py:587: in fail raise ValidationError(message_string, code=key) E rest_framework.exceptions.ValidationError: ['Invalid hyperlink - Object does not exist.']
Space character ' '
is prohibited in IRIs, therefore we shouldn't rely on encoding %20
to ' '
in the HyperlinkedRelatedField
tests. It was fixed in Django 2.0 (see django/django@03281d8).