diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py index 2b911d4dc5..4b8db72e5d 100644 --- a/tests/model_inheritance/tests.py +++ b/tests/model_inheritance/tests.py @@ -449,6 +449,12 @@ class ModelInheritanceDataTests(TestCase): with self.assertRaises(Place.MultipleObjectsReturned): Restaurant.objects.get() + def test_inherited_not_updated_exception(self): + # NotUpdated is also inherited. + obj = Restaurant(id=999) + with self.assertRaises(Place.NotUpdated): + obj.save(update_fields={"name"}) + def test_related_objects_for_inherited_models(self): # Related objects work just as they normally do. s1 = Supplier.objects.create(name="Joe's Chickens", address="123 Sesame St") diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py index 7caa43d489..98bba949f5 100644 --- a/tests/proxy_models/tests.py +++ b/tests/proxy_models/tests.py @@ -2,7 +2,7 @@ from django.contrib import admin from django.contrib.auth.models import User as AuthUser from django.contrib.contenttypes.models import ContentType from django.core import checks, management -from django.db import DEFAULT_DB_ALIAS, models +from django.db import DEFAULT_DB_ALIAS, models, transaction from django.db.models import signals from django.test import TestCase, override_settings from django.test.utils import isolate_apps @@ -104,8 +104,8 @@ class ProxyModelTests(TestCase): def test_proxy_included_in_ancestors(self): """ - Proxy models are included in the ancestors for a model's DoesNotExist - and MultipleObjectsReturned + Proxy models are included in the ancestors for a model's DoesNotExist, + MultipleObjectsReturned, and NotUpdated """ Person.objects.create(name="Foo McBar") MyPerson.objects.create(name="Bazza del Frob") @@ -118,6 +118,8 @@ class ProxyModelTests(TestCase): MyPersonProxy.objects.get(id__lt=max_id + 1) with self.assertRaises(Person.DoesNotExist): StatusPerson.objects.get(name="Zathras") + with self.assertRaises(Person.NotUpdated), transaction.atomic(): + StatusPerson(id=999).save(update_fields={"name"}) StatusPerson.objects.create(name="Bazza Jr.") StatusPerson.objects.create(name="Foo Jr.") diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py index 074a8ed550..e1e4c9a2f8 100644 --- a/tests/queryset_pickle/tests.py +++ b/tests/queryset_pickle/tests.py @@ -70,6 +70,10 @@ class PickleabilityTestCase(TestCase): klass = Event.MultipleObjectsReturned self.assertIs(pickle.loads(pickle.dumps(klass)), klass) + def test_not_updated_class(self): + klass = Event.NotUpdated + self.assertIs(pickle.loads(pickle.dumps(klass)), klass) + def test_forward_relatedobjectdoesnotexist_class(self): # ForwardManyToOneDescriptor klass = Event.group.RelatedObjectDoesNotExist