1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #21563 -- Single related object descriptors should work with hasattr.

Thanks to Aymeric Augustin for the review and Trac alias monkut for the report.
This commit is contained in:
Simon Charette
2013-12-08 14:12:01 -05:00
parent c7c647419c
commit 75924cfa6d
3 changed files with 45 additions and 7 deletions

View File

@@ -25,6 +25,10 @@ class OneToOneTests(TestCase):
# p2 doesn't have an associated restaurant.
with self.assertRaisesMessage(Restaurant.DoesNotExist, 'Place has no restaurant'):
self.p2.restaurant
# The exception raised on attribute access when a related object
# doesn't exist should be an instance of a subclass of `AttributeError`
# refs #21563
self.assertFalse(hasattr(self.p2, 'restaurant'))
def test_setter(self):
# Set the place using assignment notation. Because place is the primary