summaryrefslogtreecommitdiff
path: root/tests/m2m_regress
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-09-30 18:18:33 +0200
committerGitHub <noreply@github.com>2022-09-30 18:18:33 +0200
commit5e0aa362d91d000984995ce374c2d7547d8d107f (patch)
treecb81db29ee76b4c0bb235366de83c130d8dddfaa /tests/m2m_regress
parent6cc0f22a73970dd7c0d29d4d8d2ff9e1cc862b30 (diff)
downloaddjango-5e0aa362d91d000984995ce374c2d7547d8d107f.tar.gz
Fixed #33984 -- Reverted "Fixed #32980 -- Made models cache related managers."
This reverts 4f8c7fd9d91b35e2c2922de4bb50c8c8066cbbc6 and adds two regression tests: - test_related_manager_refresh(), and - test_create_copy_with_m2m(). Thanks joeli for the report.
Diffstat (limited to 'tests/m2m_regress')
-rw-r--r--tests/m2m_regress/tests.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/tests/m2m_regress/tests.py b/tests/m2m_regress/tests.py
index d5ad559e85..d3f352ffd9 100644
--- a/tests/m2m_regress/tests.py
+++ b/tests/m2m_regress/tests.py
@@ -39,14 +39,6 @@ class M2MRegressionTests(TestCase):
self.assertSequenceEqual(e1.topics.all(), [t1])
self.assertSequenceEqual(e1.related.all(), [t2])
- def test_m2m_managers_reused(self):
- s1 = SelfRefer.objects.create(name="s1")
- e1 = Entry.objects.create(name="e1")
- self.assertIs(s1.references, s1.references)
- self.assertIs(s1.related, s1.related)
- self.assertIs(e1.topics, e1.topics)
- self.assertIs(e1.related, e1.related)
-
def test_internal_related_name_not_in_error_msg(self):
# The secret internal related names for self-referential many-to-many
# fields shouldn't appear in the list when an error is made.
@@ -79,6 +71,20 @@ class M2MRegressionTests(TestCase):
w.save()
w.delete()
+ def test_create_copy_with_m2m(self):
+ t1 = Tag.objects.create(name="t1")
+ Entry.objects.create(name="e1")
+ entry = Entry.objects.first()
+ entry.topics.set([t1])
+ old_topics = entry.topics.all()
+ entry.pk = None
+ entry._state.adding = True
+ entry.save()
+ entry.topics.set(old_topics)
+ entry = Entry.objects.get(pk=entry.pk)
+ self.assertCountEqual(entry.topics.all(), old_topics)
+ self.assertSequenceEqual(entry.topics.all(), [t1])
+
def test_add_m2m_with_base_class(self):
# Regression for #11956 -- You can add an object to a m2m with the
# base class without causing integrity errors