diff options
author | Raphael Merx <raphaelm@captricity.com> | 2015-09-16 19:49:40 -0700 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2015-09-19 20:49:13 -0400 |
commit | f5a33e4840d3ad4d1199e99f5a17a9af1d2176f9 (patch) | |
tree | a9530812e668f40b1b3fb006c95e80a149550d2d /tests/one_to_one | |
parent | c21410aeeb17d75f31cb45f77d4eb065fe1628e0 (diff) | |
download | django-f5a33e4840d3ad4d1199e99f5a17a9af1d2176f9.tar.gz |
Fixed #25296 -- Prevented model related object cache pollution when create() fails due to an unsaved object.
Diffstat (limited to 'tests/one_to_one')
-rw-r--r-- | tests/one_to_one/tests.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/one_to_one/tests.py b/tests/one_to_one/tests.py index 1319cf0d9b..25d20dc2c9 100644 --- a/tests/one_to_one/tests.py +++ b/tests/one_to_one/tests.py @@ -135,9 +135,14 @@ class OneToOneTests(TestCase): should raise an exception. """ place = Place(name='User', address='London') + with self.assertRaises(Restaurant.DoesNotExist): + place.restaurant msg = "save() prohibited to prevent data loss due to unsaved related object 'place'." with self.assertRaisesMessage(ValueError, msg): Restaurant.objects.create(place=place, serves_hot_dogs=True, serves_pizza=False) + # place should not cache restaurant + with self.assertRaises(Restaurant.DoesNotExist): + place.restaurant def test_reverse_relationship_cache_cascade(self): """ |