          # Ensure the fields are unique to begin with
          UniqueTest.objects.create(year=2012, slug="foo")
          UniqueTest.objects.create(year=2011, slug="foo")
          UniqueTest.objects.create(year=2011, slug="bar")
          self.assertRaises(IntegrityError, UniqueTest.objects.create, year=2012, slug="foo")
          UniqueTest.objects.all().delete()
          # Alter the model to its non-unique-together companion
          with connection.schema_editor() as editor:
              editor.alter_unique_together(UniqueTest, UniqueTest._meta.unique_together, [])
          # Ensure the fields are no longer unique
 
</s> remove         self.assertRaises(IntegrityError, UniqueTest.objects.create, year=2012, slug="foo")
 </s> add         with self.assertRaises(IntegrityError):
            UniqueTest.objects.create(year=2012, slug="foo") </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(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(IntegrityError, TagUniqueRename.objects.create, title="bar", slug2="foo")
 </s> add         with self.assertRaises(IntegrityError):
            TagUniqueRename.objects.create(title="bar", slug2="foo") </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)
        with self.assertRaises(IntegrityError):
            UniqueTest.objects.create(year=2012, slug="foo")
          # Ensure the fields are unique to begin with
          UniqueTest.objects.create(year=2012, slug="foo")
          UniqueTest.objects.create(year=2011, slug="foo")
          UniqueTest.objects.create(year=2011, slug="bar")
        with self.assertRaises(IntegrityError):
            UniqueTest.objects.create(year=2012, slug="foo")
          UniqueTest.objects.all().delete()
          # Alter the model to its non-unique-together companion
          with connection.schema_editor() as editor:
              editor.alter_unique_together(UniqueTest, UniqueTest._meta.unique_together, [])
          # Ensure the fields are no longer unique
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/schema/tests.py