diff options
| author | Tom Christie | 2014-10-10 14:16:09 +0100 | 
|---|---|---|
| committer | Tom Christie | 2014-10-10 14:16:09 +0100 | 
| commit | d9a199ca0ddf92f999aa37b396596d0e3e0a26d9 (patch) | |
| tree | c7521c3c046e5f97e52bab51aef8a5367ad52f6e /tests/test_relations.py | |
| parent | a0e852a4d52558db93209b4616f030b4ae2dcedb (diff) | |
| download | django-rest-framework-d9a199ca0ddf92f999aa37b396596d0e3e0a26d9.tar.bz2 | |
exceptions.ValidationFailed, not Django's ValidationError
Diffstat (limited to 'tests/test_relations.py')
| -rw-r--r-- | tests/test_relations.py | 20 | 
1 files changed, 10 insertions, 10 deletions
| diff --git a/tests/test_relations.py b/tests/test_relations.py index 66784195..53c1b25c 100644 --- a/tests/test_relations.py +++ b/tests/test_relations.py @@ -1,6 +1,6 @@  from .utils import mock_reverse, fail_reverse, BadType, MockObject, MockQueryset -from django.core.exceptions import ImproperlyConfigured, ValidationError -from rest_framework import serializers +from django.core.exceptions import ImproperlyConfigured +from rest_framework import exceptions, serializers  from rest_framework.test import APISimpleTestCase  import pytest @@ -30,15 +30,15 @@ class TestPrimaryKeyRelatedField(APISimpleTestCase):          assert instance is self.instance      def test_pk_related_lookup_does_not_exist(self): -        with pytest.raises(ValidationError) as excinfo: +        with pytest.raises(exceptions.ValidationFailed) as excinfo:              self.field.to_internal_value(4) -        msg = excinfo.value.messages[0] +        msg = excinfo.value.detail[0]          assert msg == "Invalid pk '4' - object does not exist."      def test_pk_related_lookup_invalid_type(self): -        with pytest.raises(ValidationError) as excinfo: +        with pytest.raises(exceptions.ValidationFailed) as excinfo:              self.field.to_internal_value(BadType()) -        msg = excinfo.value.messages[0] +        msg = excinfo.value.detail[0]          assert msg == 'Incorrect type. Expected pk value, received BadType.'      def test_pk_representation(self): @@ -120,15 +120,15 @@ class TestSlugRelatedField(APISimpleTestCase):          assert instance is self.instance      def test_slug_related_lookup_does_not_exist(self): -        with pytest.raises(ValidationError) as excinfo: +        with pytest.raises(exceptions.ValidationFailed) as excinfo:              self.field.to_internal_value('doesnotexist') -        msg = excinfo.value.messages[0] +        msg = excinfo.value.detail[0]          assert msg == 'Object with name=doesnotexist does not exist.'      def test_slug_related_lookup_invalid_type(self): -        with pytest.raises(ValidationError) as excinfo: +        with pytest.raises(exceptions.ValidationFailed) as excinfo:              self.field.to_internal_value(BadType()) -        msg = excinfo.value.messages[0] +        msg = excinfo.value.detail[0]          assert msg == 'Invalid value.'      def test_representation(self): | 
