test_deprecated_fields.py 856 B

12345678910111213141516171819202122
  1. from django.core.management import call_command
  2. from django.test import override_settings
  3. from .test_base import MigrationTestBase
  4. class Tests(MigrationTestBase):
  5. """
  6. Deprecated model fields should still be usable in historic migrations.
  7. """
  8. @override_settings(MIGRATION_MODULES={"migrations": "migrations.deprecated_field_migrations"})
  9. def test_migrate(self):
  10. # Make sure no tables are created
  11. self.assertTableNotExists("migrations_ipaddressfield")
  12. # Run migration
  13. call_command("migrate", verbosity=0)
  14. # Make sure the right tables exist
  15. self.assertTableExists("migrations_ipaddressfield")
  16. # Unmigrate everything
  17. call_command("migrate", "migrations", "zero", verbosity=0)
  18. # Make sure it's all gone
  19. self.assertTableNotExists("migrations_ipaddressfield")