aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_relations.py
diff options
context:
space:
mode:
authorTom Christie2014-10-17 13:23:14 +0100
committerTom Christie2014-10-17 13:23:14 +0100
commit05cbec9dd7f9f0b6a9b59b29ac6c9272b6ae50d8 (patch)
treede0da30019c3f0d3ac34bfa3317767fc6e6ad36f /tests/test_relations.py
parent5882a7a9d52de1084d2be68adc73dc19bc706e4a (diff)
downloaddjango-rest-framework-05cbec9dd7f9f0b6a9b59b29ac6c9272b6ae50d8.tar.bz2
Use serializers.ValidationError
Diffstat (limited to 'tests/test_relations.py')
-rw-r--r--tests/test_relations.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_relations.py b/tests/test_relations.py
index 53c1b25c..16ead1f2 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
-from rest_framework import exceptions, serializers
+from rest_framework import serializers
from rest_framework.test import APISimpleTestCase
import pytest
@@ -30,13 +30,13 @@ class TestPrimaryKeyRelatedField(APISimpleTestCase):
assert instance is self.instance
def test_pk_related_lookup_does_not_exist(self):
- with pytest.raises(exceptions.ValidationFailed) as excinfo:
+ with pytest.raises(serializers.ValidationError) as excinfo:
self.field.to_internal_value(4)
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(exceptions.ValidationFailed) as excinfo:
+ with pytest.raises(serializers.ValidationError) as excinfo:
self.field.to_internal_value(BadType())
msg = excinfo.value.detail[0]
assert msg == 'Incorrect type. Expected pk value, received BadType.'
@@ -120,13 +120,13 @@ class TestSlugRelatedField(APISimpleTestCase):
assert instance is self.instance
def test_slug_related_lookup_does_not_exist(self):
- with pytest.raises(exceptions.ValidationFailed) as excinfo:
+ with pytest.raises(serializers.ValidationError) as excinfo:
self.field.to_internal_value('doesnotexist')
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(exceptions.ValidationFailed) as excinfo:
+ with pytest.raises(serializers.ValidationError) as excinfo:
self.field.to_internal_value(BadType())
msg = excinfo.value.detail[0]
assert msg == 'Invalid value.'