          # but this approximates that in a way that's easier in tests.
          School.objects.use_for_related_fields = True
          try:
              private_director = Director._base_manager.get(pk=private_director.pk)
              self.assertRaises(School.DoesNotExist, lambda: private_director.school)
          finally:
              School.objects.use_for_related_fields = False
  
          Director.objects.use_for_related_fields = True
          try:
 
</s> remove             self.assertRaises(Director.DoesNotExist, lambda: private_school.director)
 </s> add             with self.assertRaises(Director.DoesNotExist):
                private_school.director </s> remove         self.assertRaises(IOError, lambda: file_move_safe(self.file_a, self.file_b, allow_overwrite=False))
 </s> add         with self.assertRaises(IOError):
            file_move_safe(self.file_a, self.file_b, allow_overwrite=False) </s> remove         self.assertRaises(PermissionDenied, AView.as_view(), request)
 </s> add         with self.assertRaises(PermissionDenied):
            AView.as_view()(request) </s> remove         self.assertRaises(PermissionDenied, AView.as_view(), request)
 </s> add         with self.assertRaises(PermissionDenied):
            AView.as_view()(request) </s> remove         self.assertRaises(TypeError, build_no_base_classes)
 </s> add         with self.assertRaises(TypeError):
            build_no_base_classes()
            with self.assertRaises(School.DoesNotExist):
                private_director.school
          # but this approximates that in a way that's easier in tests.
          School.objects.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
  
          Director.objects.use_for_related_fields = True
          try:
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/one_to_one/tests.py