mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
This reverts 4f8c7fd9d9 and adds
two regression tests:
- test_related_manager_refresh(), and
- test_create_copy_with_m2m().
Thanks joeli for the report.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user