diff options
| author | Jim Nicholls <jim.nicholls@sydney.edu.au> | 2016-08-13 19:33:58 +1000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-08-18 08:27:40 -0400 |
| commit | 76ab8851181675a59425f9637bdbf3f2de95f6f1 (patch) | |
| tree | ad5cd724aa8ed4546ad28ae440bd25a462859ccd /tests/migrations/test_loader.py | |
| parent | 97513269d73520d10722bbd10404be6ac4d48d07 (diff) | |
Fixed #27054 -- Fixed makemigrations crash with a read-only database.
Diffstat (limited to 'tests/migrations/test_loader.py')
| -rw-r--r-- | tests/migrations/test_loader.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py index c97cddb913..b46f35f7ed 100644 --- a/tests/migrations/test_loader.py +++ b/tests/migrations/test_loader.py @@ -4,11 +4,12 @@ from unittest import skipIf from django.db import connection, connections from django.db.migrations.exceptions import ( - AmbiguityError, InconsistentMigrationHistory, NodeNotFoundError, + AmbiguityError, InconsistentMigrationHistory, MigrationSchemaMissing, + NodeNotFoundError, ) from django.db.migrations.loader import MigrationLoader from django.db.migrations.recorder import MigrationRecorder -from django.test import TestCase, modify_settings, override_settings +from django.test import TestCase, mock, modify_settings, override_settings from django.utils import six @@ -464,3 +465,12 @@ class LoaderTests(TestCase): ('app1', '4_auto'), } self.assertEqual(plan, expected_plan) + + def test_readonly_database(self): + """ + check_consistent_history() ignores read-only databases, possibly + without a django_migrations table. + """ + with mock.patch.object(MigrationRecorder, 'ensure_schema', side_effect=MigrationSchemaMissing()): + loader = MigrationLoader(connection=None) + loader.check_consistent_history(connection) |
