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