          # Remove the M2M table again
          with connection.schema_editor() as editor:
              editor.remove_field(LocalAuthorWithM2M, new_field)
          # Ensure there's no m2m table there
          self.assertRaises(DatabaseError, self.column_classes, new_field.remote_field.through)
  
          # Make sure the model state is coherent with the table one now that
          # we've removed the tags field.
          opts = LocalAuthorWithM2M._meta
          opts.local_many_to_many.remove(new_field)
 
</s> remove         self.assertRaises(DatabaseError, self.column_classes, new_field.remote_field.through)
 </s> add         with self.assertRaises(DatabaseError):
            self.column_classes(new_field.remote_field.through) </s> remove         self.assertRaises(
            DatabaseError,
            self.column_classes, LocalBookWithM2M._meta.get_field("tags").remote_field.through
        )
 </s> add         with self.assertRaises(DatabaseError):
            self.column_classes(LocalBookWithM2M._meta.get_field("tags").remote_field.through) </s> remove         self.assertRaises(
            DatabaseError,
            lambda: list(Author.objects.all()),
        )
 </s> add         with self.assertRaises(DatabaseError):
            list(Author.objects.all()) </s> remove         self.assertRaises(IntegrityError, Tag.objects.create, title="bar", slug="foo")
 </s> add         with self.assertRaises(IntegrityError):
            Tag.objects.create(title="bar", slug="foo") </s> remove         self.assertRaises(
            DatabaseError,
            lambda: list(Thing.objects.all()),
        )
 </s> add         with self.assertRaises(DatabaseError):
            list(Thing.objects.all())
        with self.assertRaises(DatabaseError):
            self.column_classes(new_field.remote_field.through)
          # Remove the M2M table again
          with connection.schema_editor() as editor:
              editor.remove_field(LocalAuthorWithM2M, new_field)
          # Ensure there's no m2m table there
        with self.assertRaises(DatabaseError):
            self.column_classes(new_field.remote_field.through)
  
          # Make sure the model state is coherent with the table one now that
          # we've removed the tags field.
          opts = LocalAuthorWithM2M._meta
          opts.local_many_to_many.remove(new_field)
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/schema/tests.py