diff options
author | Tim Graham <timograham@gmail.com> | 2016-12-31 09:04:09 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-01-17 20:52:01 -0500 |
commit | ed251246cc6a22561217f38f7cf96598b22ff0fe (patch) | |
tree | 6e17d1affdbf331b3f1437491ba7d9bdb677c8a0 /tests/many_to_many | |
parent | e0910dcc9283cd8f782cb97836c291f6f395f3f0 (diff) | |
download | django-ed251246cc6a22561217f38f7cf96598b22ff0fe.tar.gz |
Refs #25550 -- Removed support for direct assignment to the reverse side of a related set.
Diffstat (limited to 'tests/many_to_many')
-rw-r--r-- | tests/many_to_many/tests.py | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/tests/many_to_many/tests.py b/tests/many_to_many/tests.py index 2917214471..e5bc51be47 100644 --- a/tests/many_to_many/tests.py +++ b/tests/many_to_many/tests.py @@ -1,8 +1,7 @@ from __future__ import unicode_literals from django.db import transaction -from django.test import TestCase, ignore_warnings -from django.utils.deprecation import RemovedInDjango20Warning +from django.test import TestCase from .models import Article, InheritedArticleA, InheritedArticleB, Publication @@ -400,45 +399,22 @@ class ManyToManyTests(TestCase): self.a4.publications.set([], clear=True) self.assertQuerysetEqual(self.a4.publications.all(), []) - def test_assign_forward_deprecation(self): + def test_assign_forward(self): msg = ( "Direct assignment to the reverse side of a many-to-many set is " - "deprecated due to the implicit save() that happens. Use " - "article_set.set() instead." + "prohibited. Use article_set.set() instead." ) - with self.assertRaisesMessage(RemovedInDjango20Warning, msg): + with self.assertRaisesMessage(TypeError, msg): self.p2.article_set = [self.a4, self.a3] - def test_assign_reverse_deprecation(self): + def test_assign_reverse(self): msg = ( "Direct assignment to the forward side of a many-to-many " - "set is deprecated due to the implicit save() that happens. Use " - "publications.set() instead." + "set is prohibited. Use publications.set() instead." ) - with self.assertRaisesMessage(RemovedInDjango20Warning, msg): + with self.assertRaisesMessage(TypeError, msg): self.a1.publications = [self.p1, self.p2] - @ignore_warnings(category=RemovedInDjango20Warning) - def test_assign_deprecated(self): - self.p2.article_set = [self.a4, self.a3] - self.assertQuerysetEqual( - self.p2.article_set.all(), - [ - '<Article: NASA finds intelligent life on Earth>', - '<Article: Oxygen-free diet works wonders>', - ] - ) - self.assertQuerysetEqual(self.a4.publications.all(), ['<Publication: Science News>']) - self.a4.publications = [self.p3.id] - self.assertQuerysetEqual(self.p2.article_set.all(), ['<Article: NASA finds intelligent life on Earth>']) - self.assertQuerysetEqual(self.a4.publications.all(), ['<Publication: Science Weekly>']) - - # An alternate to calling clear() is to assign the empty set - self.p2.article_set = [] - self.assertQuerysetEqual(self.p2.article_set.all(), []) - self.a4.publications = [] - self.assertQuerysetEqual(self.a4.publications.all(), []) - def test_assign(self): # Relation sets can be assigned using set(). self.p2.article_set.set([self.a4, self.a3]) |