From 6f8b2d1c6dfaab4b18a2b10bca4e54bdbabc10d8 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Tue, 3 Feb 2026 10:14:31 +0000 Subject: Refs #33579 -- Added extra tests for NotUpdated exception. When `NotUpdated` was added in ab148c02cedbac492f29930dcd5346e1af052635, these additional tests that have equivalents for the `DoesNotExist` and `MultipleObjectsReturned` exceptions were missed. --- tests/proxy_models/tests.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests/proxy_models/tests.py') 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.") -- cgit v1.3