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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user