aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/relations.py
diff options
context:
space:
mode:
authorTom Christie2013-01-04 13:05:31 +0000
committerTom Christie2013-01-04 13:05:31 +0000
commit4c86fd46d772e1fd3789d9ed2a76b9b92cce0872 (patch)
treef18c68752a0bcebf92dc8d642e16ff07ad759005 /rest_framework/tests/relations.py
parent6e9865cb71ff45e90020d3d0dc7c40f20c760d2e (diff)
downloaddjango-rest-framework-4c86fd46d772e1fd3789d9ed2a76b9b92cce0872.tar.bz2
Rename module for basic relational field tests
Diffstat (limited to 'rest_framework/tests/relations.py')
-rw-r--r--rest_framework/tests/relations.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/rest_framework/tests/relations.py b/rest_framework/tests/relations.py
new file mode 100644
index 00000000..108ec473
--- /dev/null
+++ b/rest_framework/tests/relations.py
@@ -0,0 +1,22 @@
+"""
+General tests for relational fields.
+"""
+
+from django.db import models
+from django.test import TestCase
+from rest_framework import serializers
+
+
+class NullModel(models.Model):
+ pass
+
+
+class FieldTests(TestCase):
+ def test_pk_related_field_with_empty_string(self):
+ """
+ Regression test for #446
+
+ https://github.com/tomchristie/django-rest-framework/issues/446
+ """
+ field = serializers.PrimaryKeyRelatedField(queryset=NullModel.objects.all())
+ self.assertRaises(serializers.ValidationError, field.from_native, ('',))