diff options
| author | Moayad Mardini <moayad.m@gmail.com> | 2014-05-30 01:23:09 +0300 |
|---|---|---|
| committer | Moayad Mardini <moayad.m@gmail.com> | 2014-05-30 01:23:09 +0300 |
| commit | 56cfa508c796ad317e813647eadd9f7142f6d2dc (patch) | |
| tree | 1b0a90ce5e91ba5f341e81f1f792c309226a3ef2 /tests | |
| parent | d240b29c086f434c87c2a5be7af539ceb8c0f55f (diff) | |
Fixed #22682 -- `makemigrations` will create `MIGRATION_MODULES` package
`makemigrations` will automatically create the package specified
in `MIGRATION_MODULES` if it doesn't already exist.
Thanks ovidiuc4 for the report.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_commands.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index 4783ffa0c3..4063a8db8e 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -413,3 +413,38 @@ class MakeMigrationsTests(MigrationTestBase): self.assertIn("migrations.AddField(", stdout.getvalue()) self.assertIn("model_name='sillymodel',", stdout.getvalue()) self.assertIn("name='silly_char',", stdout.getvalue()) + + @override_system_checks([]) + @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_path_doesnt_exist.foo.bar"}) + def test_makemigrations_migrations_modules_path_not_exist(self): + """ + Ticket #22682 -- Makemigrations fails when specifying custom location + for migration files (using MIGRATION_MODULES) if the custom path + doesn't already exist. + """ + + class SillyModel(models.Model): + silly_field = models.BooleanField(default=False) + + class Meta: + app_label = "migrations" + + stdout = six.StringIO() + call_command("makemigrations", "migrations", stdout=stdout) + + # Command output indicates the migration is created. + self.assertIn(" - Create model SillyModel", stdout.getvalue()) + + # Migrations file is actually created in the expected path. + self.assertTrue(os.path.isfile(os.path.join(self.test_dir, + "test_migrations_path_doesnt_exist", "foo", "bar", + "0001_initial.py"))) + + os.chdir(self.test_dir) + try: + self._rmrf(os.path.join(self.test_dir, + "test_migrations_path_doesnt_exist")) + pass + except OSError: + pass + os.chdir(self._cwd) |
