summaryrefslogtreecommitdiff
path: root/tests/one_to_one
diff options
context:
space:
mode:
authorPaulo <commonzenpython@gmail.com>2017-10-29 12:01:04 +0100
committerTim Graham <timograham@gmail.com>2017-10-30 14:02:03 -0400
commitfcfcf8aae470d893b0d2ef176434461edf9e9c4d (patch)
treebe88eadca0590238973412d0239542252f305c2d /tests/one_to_one
parentf8946fbb5d7e8eb6c8ca7481b0cd4e78627ef8cf (diff)
downloaddjango-fcfcf8aae470d893b0d2ef176434461edf9e9c4d.tar.gz
Fixed #28742 -- Fixed AttributeError crash when assigning None to cached reverse relations.
Diffstat (limited to 'tests/one_to_one')
-rw-r--r--tests/one_to_one/tests.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/one_to_one/tests.py b/tests/one_to_one/tests.py
index 65257cf7dc..314c56a60f 100644
--- a/tests/one_to_one/tests.py
+++ b/tests/one_to_one/tests.py
@@ -196,6 +196,15 @@ class OneToOneTests(TestCase):
# UndergroundBar.
p.undergroundbar = None
+ def test_assign_none_to_null_cached_reverse_relation(self):
+ p = Place.objects.get(name='Demon Dogs')
+ # Prime the relation's cache with a value of None.
+ with self.assertRaises(Place.undergroundbar.RelatedObjectDoesNotExist):
+ getattr(p, 'undergroundbar')
+ # Assigning None works if there isn't a related UndergroundBar and the
+ # reverse cache has a value of None.
+ p.undergroundbar = None
+
def test_related_object_cache(self):
""" Regression test for #6886 (the related-object cache) """