diff options
| author | Nick Pope <nick@nickpope.me.uk> | 2026-02-03 10:14:31 +0000 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-02-05 09:18:55 -0500 |
| commit | 6f8b2d1c6dfaab4b18a2b10bca4e54bdbabc10d8 (patch) | |
| tree | b93bbfa765d1887560bf41d3137a330c9d8dab97 /tests/proxy_models/tests.py | |
| parent | 13299a6203f4bc3e5b2552c96a51ff2b15da3c43 (diff) | |
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.
Diffstat (limited to 'tests/proxy_models/tests.py')
| -rw-r--r-- | tests/proxy_models/tests.py | 8 |
1 files changed, 5 insertions, 3 deletions
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.") |
