Fixed #20932, #25897 -- Streamlined manager inheritance.

This commit is contained in:
Loïc Bistuer 2016-02-19 02:27:55 +07:00
parent 9935f97cd2
commit 3a47d42fa3
12 changed files with 112 additions and 218 deletions

View file

@ -457,21 +457,21 @@ class OneToOneTests(TestCase):
# If the manager is marked "use_for_related_fields", it'll get used instead
# of the "bare" queryset. Usually you'd define this as a property on the class,
# but this approximates that in a way that's easier in tests.
School.objects.use_for_related_fields = True
School._default_manager.use_for_related_fields = True
try:
private_director = Director._base_manager.get(pk=private_director.pk)
with self.assertRaises(School.DoesNotExist):
private_director.school
finally:
School.objects.use_for_related_fields = False
School._default_manager.use_for_related_fields = False
Director.objects.use_for_related_fields = True
Director._default_manager.use_for_related_fields = True
try:
private_school = School._base_manager.get(pk=private_school.pk)
with self.assertRaises(Director.DoesNotExist):
private_school.director
finally:
Director.objects.use_for_related_fields = False
Director._default_manager.use_for_related_fields = False
def test_hasattr_related_object(self):
# The exception raised on attribute access when a related object