test_index_together_deprecation.py 688 B

1234567891011121314151617181920
  1. from django.db import models
  2. from django.test import TestCase
  3. from django.utils.deprecation import RemovedInDjango51Warning
  4. class IndexTogetherDeprecationTests(TestCase):
  5. def test_warning(self):
  6. msg = (
  7. "'index_together' is deprecated. Use 'Meta.indexes' in "
  8. "'model_options.MyModel' instead."
  9. )
  10. with self.assertRaisesMessage(RemovedInDjango51Warning, msg):
  11. class MyModel(models.Model):
  12. field_1 = models.IntegerField()
  13. field_2 = models.IntegerField()
  14. class Meta:
  15. app_label = "model_options"
  16. index_together = ["field_1", "field_2"]