          p = Person.objects.create(name="Marty Alchin")
          b.authors.set([p])
          b.editor = p
          with self.override_router():
              self.assertRaises(AttributeError, b.delete)
  
      def test_attribute_error_m2m(self):
          "Check that the AttributeError from AttributeErrorRouter bubbles up"
          b = Book.objects.create(title="Pro Django",
                                  published=datetime.date(2008, 12, 16))
 
</s> remove             self.assertRaises(AttributeError, Book.objects.get, pk=b.pk)
 </s> add             with self.assertRaises(AttributeError):
                Book.objects.get(pk=b.pk) </s> remove             self.assertRaises(AttributeError, dive.save)
 </s> add             with self.assertRaises(AttributeError):
                dive.save() </s> remove         self.assertRaises(IndexError, p._checkindex, 2)
        self.assertRaises(IndexError, p._checkindex, -3)
 </s> add         with self.assertRaises(IndexError):
            p._checkindex(2)
        with self.assertRaises(IndexError):
            p._checkindex(-3) </s> remove         self.assertRaises(Http404, shortcut, request, user_ct.id, obj.id)
 </s> add         with self.assertRaises(Http404):
            shortcut(request, user_ct.id, obj.id) </s> remove             self.assertRaises(TypeError, poly.__setitem__, 0, LineString((1, 1), (2, 2)))
 </s> add             with self.assertRaises(TypeError):
                poly.__setitem__(0, LineString((1, 1), (2, 2)))
            with self.assertRaises(AttributeError):
                b.delete()
          p = Person.objects.create(name="Marty Alchin")
          b.authors.set([p])
          b.editor = p
          with self.override_router():
            with self.assertRaises(AttributeError):
                b.delete()
  
      def test_attribute_error_m2m(self):
          "Check that the AttributeError from AttributeErrorRouter bubbles up"
          b = Book.objects.create(title="Pro Django",
                                  published=datetime.date(2008, 12, 16))
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/multiple_database/tests.py