summaryrefslogtreecommitdiff
path: root/tests/many_to_many
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2019-11-22 08:39:54 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-11-22 09:04:03 +0100
commit8cc711999ab839c1a93cb228b35beac4a454fafc (patch)
treedba0fd9faefa307e2297381211b4b13eb5cff27f /tests/many_to_many
parentee4a19053a32d41cdd79e087b1968980804ce658 (diff)
downloaddjango-8cc711999ab839c1a93cb228b35beac4a454fafc.tar.gz
Refs #8467 -- Added test for RelatedManager.add()/remove() with an invalid type.
Diffstat (limited to 'tests/many_to_many')
-rw-r--r--tests/many_to_many/tests.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/many_to_many/tests.py b/tests/many_to_many/tests.py
index 8ff1185878..a60ea42430 100644
--- a/tests/many_to_many/tests.py
+++ b/tests/many_to_many/tests.py
@@ -104,6 +104,12 @@ class ManyToManyTests(TestCase):
a5.authors.remove(user_2.username)
self.assertQuerysetEqual(a5.authors.all(), [])
+ def test_add_remove_invalid_type(self):
+ msg = "Field 'id' expected a number but got 'invalid'."
+ for method in ['add', 'remove']:
+ with self.subTest(method), self.assertRaisesMessage(ValueError, msg):
+ getattr(self.a1.publications, method)('invalid')
+
def test_reverse_add(self):
# Adding via the 'other' end of an m2m
a5 = Article(headline='NASA finds intelligent life on Mars')