Refs #30651 -- Added tests for Prefetch.__eq__().

This commit is contained in:
Mariusz Felisiak 2019-10-01 17:30:02 +02:00
parent 0d4b40fe66
commit 6475e6318c
1 changed files with 6 additions and 0 deletions

View File

@ -239,6 +239,12 @@ class PrefetchRelatedTests(TestDataMixin, TestCase):
self.assertIn('prefetch_related', str(cm.exception)) self.assertIn('prefetch_related', str(cm.exception))
self.assertIn("name", str(cm.exception)) self.assertIn("name", str(cm.exception))
def test_prefetch_eq(self):
prefetch_1 = Prefetch('authors', queryset=Author.objects.all())
prefetch_2 = Prefetch('books', queryset=Book.objects.all())
self.assertEqual(prefetch_1, prefetch_1)
self.assertNotEqual(prefetch_1, prefetch_2)
def test_forward_m2m_to_attr_conflict(self): def test_forward_m2m_to_attr_conflict(self):
msg = 'to_attr=authors conflicts with a field on the Book model.' msg = 'to_attr=authors conflicts with a field on the Book model.'
authors = Author.objects.all() authors = Author.objects.all()