summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEgidijus Macijauskas <e.macijauskas@outlook.com>2021-02-09 23:43:01 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-02-11 09:09:59 +0100
commitaa1aed923b391b56d514be499c4ddf4b5110b377 (patch)
tree20b3abbce49351de4b37799516ed977af5decfe1 /tests
parent98ce39b5a35c9d47b6c34764152fb3b1d2569c3e (diff)
[3.2.x] Fixed #32433 -- Added error message on QuerySet.delete() following distinct().
Backport of 6307c3f1a123f5975c73b231e8ac4f115fd72c0d from master
Diffstat (limited to 'tests')
-rw-r--r--tests/delete_regress/tests.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/delete_regress/tests.py b/tests/delete_regress/tests.py
index e4fa59e89f..97a7d6ba02 100644
--- a/tests/delete_regress/tests.py
+++ b/tests/delete_regress/tests.py
@@ -1,7 +1,9 @@
import datetime
from django.db import connection, models, transaction
-from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
+from django.test import (
+ SimpleTestCase, TestCase, TransactionTestCase, skipUnlessDBFeature,
+)
from .models import (
Award, AwardNote, Book, Child, Contact, Eaten, Email, File, Food, FooFile,
@@ -352,3 +354,12 @@ class DeleteTests(TestCase):
self.assertEqual(researcher1.secondary_contact, contact2)
self.assertEqual(researcher2.primary_contact, contact2)
self.assertIsNone(researcher2.secondary_contact)
+
+
+class DeleteDistinct(SimpleTestCase):
+ def test_disallowed_delete_distinct(self):
+ msg = 'Cannot call delete() after .distinct().'
+ with self.assertRaisesMessage(TypeError, msg):
+ Book.objects.distinct().delete()
+ with self.assertRaisesMessage(TypeError, msg):
+ Book.objects.distinct('id').delete()