Ticket #26930: 26930-test.diff

File 26930-test.diff, 1.5 KB (added by Claude Paroz, 8 years ago)

Failing test case

  • tests/migrations/test_commands.py

    diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
    index c9efa09..7678257 100644
    a b import sys  
    99
    1010from django.apps import apps
    1111from django.core.management import CommandError, call_command
    12 from django.db import DatabaseError, connection, connections, models
     12from django.db import (
     13    ConnectionHandler, DatabaseError, connection, connections, models,
     14)
    1315from django.db.migrations.exceptions import InconsistentMigrationHistory
    1416from django.db.migrations.recorder import MigrationRecorder
    1517from django.test import ignore_warnings, mock, override_settings
    class MakeMigrationsTests(MigrationTestBase):  
    580582            call_command('makemigrations', 'migrations', '--empty', '-n', 'a', '-v', '0')
    581583            self.assertTrue(os.path.exists(os.path.join(migration_dir, '0002_a.py')))
    582584
     585    def test_makemigrations_empty_connections(self):
     586        empty_connections = ConnectionHandler({
     587            'default': {},
     588        })
     589        with mock.patch('django.core.management.commands.makemigrations.connections', new=empty_connections):
     590            with self.temporary_migration_module() as migration_dir:
     591                call_command('makemigrations', verbosity=0)
     592
    583593    def test_failing_migration(self):
    584594        # If a migration fails to serialize, it shouldn't generate an empty file. #21280
    585595        apps.register_model('migrations', UnserializableModel)
Back to Top