summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/many_to_one/tests.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py
index d769b206b9..76ef4921dd 100644
--- a/tests/many_to_one/tests.py
+++ b/tests/many_to_one/tests.py
@@ -733,3 +733,14 @@ class ManyToOneTests(TestCase):
child = parent.to_field_children.get()
with self.assertNumQueries(0):
self.assertIs(child.parent, parent)
+
+ def test_add_remove_set_by_pk_raises(self):
+ usa = Country.objects.create(name='United States')
+ chicago = City.objects.create(name='Chicago')
+ msg = "'City' instance expected, got %s" % chicago.pk
+ with self.assertRaisesMessage(TypeError, msg):
+ usa.cities.add(chicago.pk)
+ with self.assertRaisesMessage(TypeError, msg):
+ usa.cities.remove(chicago.pk)
+ with self.assertRaisesMessage(TypeError, msg):
+ usa.cities.set([chicago.pk])