diff options
| author | za <za@python.or.id> | 2016-10-27 14:53:39 +0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-11-10 21:30:21 -0500 |
| commit | 321e94fa41b121f65c02119c02098df327bbd569 (patch) | |
| tree | ce5476c191d589aca4b124f841dfbccac8dd299f /tests/migrations | |
| parent | 4bb70cbcc60794f515c9bfefeca87b8272d33c0c (diff) | |
Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings.
Diffstat (limited to 'tests/migrations')
| -rw-r--r-- | tests/migrations/test_autodetector.py | 80 | ||||
| -rw-r--r-- | tests/migrations/test_commands.py | 108 | ||||
| -rw-r--r-- | tests/migrations/test_executor.py | 6 | ||||
| -rw-r--r-- | tests/migrations/test_graph.py | 4 | ||||
| -rw-r--r-- | tests/migrations/test_multidb.py | 2 | ||||
| -rw-r--r-- | tests/migrations/test_operations.py | 26 | ||||
| -rw-r--r-- | tests/migrations/test_optimizer.py | 8 | ||||
| -rw-r--r-- | tests/migrations/test_state.py | 29 |
8 files changed, 129 insertions, 134 deletions
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py index b5d9da07d3..bf31831071 100644 --- a/tests/migrations/test_autodetector.py +++ b/tests/migrations/test_autodetector.py @@ -603,8 +603,7 @@ class AutodetectorTests(TestCase): def test_trim_apps(self): """ - Tests that trim does not remove dependencies but does remove unwanted - apps. + Trim does not remove dependencies but does remove unwanted apps. """ # Use project state to make a new migration change set before = self.make_project_state([]) @@ -874,7 +873,7 @@ class AutodetectorTests(TestCase): def test_rename_model_with_fks_in_different_position(self): """ - #24537 - Tests that the order of fields in a model does not influence + #24537 - The order of fields in a model does not influence the RenameModel detection. """ before = [ @@ -903,7 +902,7 @@ class AutodetectorTests(TestCase): self.assertOperationAttributes(changes, "testapp", 0, 0, old_name="EntityB", new_name="RenamedEntityB") def test_fk_dependency(self): - """Tests that having a ForeignKey automatically adds a dependency.""" + """Having a ForeignKey automatically adds a dependency.""" # Note that testapp (author) has no dependencies, # otherapp (book) depends on testapp (author), # thirdapp (edition) depends on otherapp (book) @@ -925,7 +924,7 @@ class AutodetectorTests(TestCase): self.assertMigrationDependencies(changes, 'thirdapp', 0, [("otherapp", "auto_1")]) def test_proxy_fk_dependency(self): - """Tests that FK dependencies still work on proxy models.""" + """FK dependencies still work on proxy models.""" # Note that testapp (author) has no dependencies, # otherapp (book) depends on testapp (authorproxy) changes = self.get_changes([], [self.author_empty, self.author_proxy_third, self.book_proxy_fk]) @@ -947,7 +946,7 @@ class AutodetectorTests(TestCase): def test_same_app_no_fk_dependency(self): """ - Tests that a migration with a FK between two models of the same app + A migration with a FK between two models of the same app does not have a dependency to itself. """ changes = self.get_changes([], [self.author_with_publisher, self.publisher]) @@ -961,7 +960,7 @@ class AutodetectorTests(TestCase): def test_circular_fk_dependency(self): """ - Tests that having a circular ForeignKey dependency automatically + Having a circular ForeignKey dependency automatically resolves the situation into 2 migrations on one side and 1 on the other. """ changes = self.get_changes([], [self.author_with_book, self.book, self.publisher_with_book]) @@ -983,7 +982,7 @@ class AutodetectorTests(TestCase): def test_same_app_circular_fk_dependency(self): """ - Tests that a migration with a FK between two models of the same app does + A migration with a FK between two models of the same app does not have a dependency to itself. """ changes = self.get_changes([], [self.author_with_publisher, self.publisher_with_author]) @@ -997,7 +996,7 @@ class AutodetectorTests(TestCase): def test_same_app_circular_fk_dependency_with_unique_together_and_indexes(self): """ - #22275 - Tests that a migration with circular FK dependency does not try + #22275 - A migration with circular FK dependency does not try to create unique together constraint and indexes before creating all required fields first. """ @@ -1037,8 +1036,7 @@ class AutodetectorTests(TestCase): def test_alter_db_table_no_changes(self): """ - Tests that alter_db_table doesn't generate a migration if no changes - have been made. + Alter_db_table doesn't generate a migration if no changes have been made. """ changes = self.get_changes([self.author_with_db_table_options], [self.author_with_db_table_options]) # Right number of migrations? @@ -1233,7 +1231,7 @@ class AutodetectorTests(TestCase): def test_foo_together_no_changes(self): """ - Tests that index/unique_together doesn't generate a migration if no + index/unique_together doesn't generate a migration if no changes have been made. """ changes = self.get_changes( @@ -1244,7 +1242,7 @@ class AutodetectorTests(TestCase): def test_foo_together_ordering(self): """ - Tests that index/unique_together also triggers on ordering changes. + index/unique_together also triggers on ordering changes. """ changes = self.get_changes( [self.author_empty, self.book_foo_together], [self.author_empty, self.book_foo_together_2] @@ -1257,8 +1255,7 @@ class AutodetectorTests(TestCase): def test_add_field_and_foo_together(self): """ - Tests that added fields will be created before using them in - index/unique_together. + Added fields will be created before using them in index/unique_together. """ changes = self.get_changes([self.author_empty, self.book], [self.author_empty, self.book_foo_together_3]) # Right number/type of migrations? @@ -1294,8 +1291,7 @@ class AutodetectorTests(TestCase): def test_remove_field_and_foo_together(self): """ - Tests that removed fields will be removed after updating - index/unique_together. + Removed fields will be removed after updating index/unique_together. """ changes = self.get_changes( [self.author_empty, self.book_foo_together_3], [self.author_empty, self.book_foo_together] @@ -1309,8 +1305,7 @@ class AutodetectorTests(TestCase): def test_rename_field_and_foo_together(self): """ - Tests that removed fields will be removed after updating - index/unique_together. + Removed fields will be removed after updating index/unique_together. """ changes = self.get_changes( [self.author_empty, self.book_foo_together_3], @@ -1326,7 +1321,7 @@ class AutodetectorTests(TestCase): self.assertOperationAttributes(changes, "otherapp", 0, 2, name="book", index_together={("title", "newfield2")}) def test_proxy(self): - """Tests that the autodetector correctly deals with proxy models.""" + """The autodetector correctly deals with proxy models.""" # First, we test adding a proxy model changes = self.get_changes([self.author_empty], [self.author_empty, self.author_proxy]) # Right number/type of migrations? @@ -1428,7 +1423,7 @@ class AutodetectorTests(TestCase): self.assertEqual(changes['otherapp'][0].operations[0].field.remote_field.field_name, 'author_ptr') def test_unmanaged_create(self): - """Tests that the autodetector correctly deals with managed models.""" + """The autodetector correctly deals with managed models.""" # First, we test adding an unmanaged model changes = self.get_changes([self.author_empty], [self.author_empty, self.author_unmanaged]) # Right number/type of migrations? @@ -1749,7 +1744,7 @@ class AutodetectorTests(TestCase): def test_concrete_field_changed_to_many_to_many(self): """ - #23938 - Tests that changing a concrete field into a ManyToManyField + #23938 - Changing a concrete field into a ManyToManyField first removes the concrete field and then adds the m2m field. """ changes = self.get_changes([self.author_with_former_m2m], [self.author_with_m2m, self.publisher]) @@ -1762,7 +1757,7 @@ class AutodetectorTests(TestCase): def test_many_to_many_changed_to_concrete_field(self): """ - #23938 - Tests that changing a ManyToManyField into a concrete field + #23938 - Changing a ManyToManyField into a concrete field first removes the m2m field and then adds the concrete field. """ changes = self.get_changes([self.author_with_m2m, self.publisher], [self.author_with_former_m2m]) @@ -1819,7 +1814,7 @@ class AutodetectorTests(TestCase): }) def test_set_alter_order_with_respect_to(self): - """Tests that setting order_with_respect_to adds a field.""" + """Setting order_with_respect_to adds a field.""" changes = self.get_changes([self.book, self.author_with_book], [self.book, self.author_with_book_order_wrt]) # Right number/type of migrations? self.assertNumberMigrations(changes, 'testapp', 1) @@ -1828,7 +1823,7 @@ class AutodetectorTests(TestCase): def test_add_alter_order_with_respect_to(self): """ - Tests that setting order_with_respect_to when adding the FK too does + Setting order_with_respect_to when adding the FK too does things in the right order. """ changes = self.get_changes([self.author_name], [self.book, self.author_with_book_order_wrt]) @@ -1840,7 +1835,7 @@ class AutodetectorTests(TestCase): def test_remove_alter_order_with_respect_to(self): """ - Tests that removing order_with_respect_to when removing the FK too does + Removing order_with_respect_to when removing the FK too does things in the right order. """ changes = self.get_changes([self.book, self.author_with_book_order_wrt], [self.author_name]) @@ -1852,7 +1847,7 @@ class AutodetectorTests(TestCase): def test_add_model_order_with_respect_to(self): """ - Tests that setting order_with_respect_to when adding the whole model + Setting order_with_respect_to when adding the whole model does things in the right order. """ changes = self.get_changes([], [self.book, self.author_with_book_order_wrt]) @@ -1864,7 +1859,7 @@ class AutodetectorTests(TestCase): def test_alter_model_managers(self): """ - Tests that changing the model managers adds a new operation. + Changing the model managers adds a new operation. """ changes = self.get_changes([self.other_pony], [self.other_pony_food]) # Right number/type of migrations? @@ -1877,7 +1872,7 @@ class AutodetectorTests(TestCase): self.assertEqual(changes['otherapp'][0].operations[0].managers[2][1].args, ('x', 'y', 3, 4)) def test_swappable_first_inheritance(self): - """Tests that swappable models get their CreateModel first.""" + """Swappable models get their CreateModel first.""" changes = self.get_changes([], [self.custom_user, self.aardvark]) # Right number/type of migrations? self.assertNumberMigrations(changes, 'thirdapp', 1) @@ -1887,7 +1882,7 @@ class AutodetectorTests(TestCase): @override_settings(AUTH_USER_MODEL="thirdapp.CustomUser") def test_swappable_first_setting(self): - """Tests that swappable models get their CreateModel first.""" + """Swappable models get their CreateModel first.""" with isolate_lru_cache(apps.get_swappable_settings_name): changes = self.get_changes([], [self.custom_user_no_inherit, self.aardvark]) # Right number/type of migrations? @@ -1897,7 +1892,7 @@ class AutodetectorTests(TestCase): self.assertOperationAttributes(changes, 'thirdapp', 0, 1, name="Aardvark") def test_bases_first(self): - """Tests that bases of other models come first.""" + """Bases of other models come first.""" changes = self.get_changes([], [self.aardvark_based_on_author, self.author_name]) # Right number/type of migrations? self.assertNumberMigrations(changes, 'testapp', 1) @@ -1906,7 +1901,7 @@ class AutodetectorTests(TestCase): self.assertOperationAttributes(changes, 'testapp', 0, 1, name="Aardvark") def test_multiple_bases(self): - """#23956 - Tests that inheriting models doesn't move *_ptr fields into AddField operations.""" + """#23956 - Inheriting models doesn't move *_ptr fields into AddField operations.""" A = ModelState("app", "A", [("a_id", models.AutoField(primary_key=True))]) B = ModelState("app", "B", [("b_id", models.AutoField(primary_key=True))]) C = ModelState("app", "C", [], bases=("app.A", "app.B")) @@ -1925,7 +1920,7 @@ class AutodetectorTests(TestCase): self.assertOperationAttributes(changes, "app", 0, 4, name="E") def test_proxy_bases_first(self): - """Tests that bases of proxies come first.""" + """Bases of proxies come first.""" changes = self.get_changes([], [self.author_empty, self.author_proxy, self.author_proxy_proxy]) # Right number/type of migrations? self.assertNumberMigrations(changes, 'testapp', 1) @@ -1936,8 +1931,7 @@ class AutodetectorTests(TestCase): def test_pk_fk_included(self): """ - Tests that a relation used as the primary key is kept as part of - CreateModel. + A relation used as the primary key is kept as part of CreateModel. """ changes = self.get_changes([], [self.aardvark_pk_fk_author, self.author_name]) # Right number/type of migrations? @@ -1948,7 +1942,7 @@ class AutodetectorTests(TestCase): def test_first_dependency(self): """ - Tests that a dependency to an app with no migrations uses __first__. + A dependency to an app with no migrations uses __first__. """ # Load graph loader = MigrationLoader(connection) @@ -1966,7 +1960,7 @@ class AutodetectorTests(TestCase): @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) def test_last_dependency(self): """ - Tests that a dependency to an app with existing migrations uses the + A dependency to an app with existing migrations uses the last migration of that app. """ # Load graph @@ -1984,7 +1978,7 @@ class AutodetectorTests(TestCase): def test_alter_fk_before_model_deletion(self): """ - Tests that ForeignKeys are altered _before_ the model they used to + ForeignKeys are altered _before_ the model they used to refer to are deleted. """ changes = self.get_changes( @@ -2000,7 +1994,7 @@ class AutodetectorTests(TestCase): def test_fk_dependency_other_app(self): """ - #23100 - Tests that ForeignKeys correctly depend on other apps' models. + #23100 - ForeignKeys correctly depend on other apps' models. """ changes = self.get_changes([self.author_name, self.book], [self.author_with_book, self.book]) # Right number/type of migrations? @@ -2011,7 +2005,7 @@ class AutodetectorTests(TestCase): def test_circular_dependency_mixed_addcreate(self): """ - #23315 - Tests that the dependency resolver knows to put all CreateModel + #23315 - The dependency resolver knows to put all CreateModel before AddField and not become unsolvable. """ address = ModelState("a", "Address", [ @@ -2039,7 +2033,7 @@ class AutodetectorTests(TestCase): @override_settings(AUTH_USER_MODEL="a.Tenant") def test_circular_dependency_swappable(self): """ - #23322 - Tests that the dependency resolver knows to explicitly resolve + #23322 - The dependency resolver knows to explicitly resolve swappable models. """ with isolate_lru_cache(apps.get_swappable_settings_name): @@ -2068,7 +2062,7 @@ class AutodetectorTests(TestCase): @override_settings(AUTH_USER_MODEL="b.Tenant") def test_circular_dependency_swappable2(self): """ - #23322 - Tests that the dependency resolver knows to explicitly resolve + #23322 - The dependency resolver knows to explicitly resolve swappable models but with the swappable not being the first migrated model. """ @@ -2097,7 +2091,7 @@ class AutodetectorTests(TestCase): @override_settings(AUTH_USER_MODEL="a.Person") def test_circular_dependency_swappable_self(self): """ - #23322 - Tests that the dependency resolver knows to explicitly resolve + #23322 - The dependency resolver knows to explicitly resolve swappable models. """ with isolate_lru_cache(apps.get_swappable_settings_name): diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index e138ef40bf..d329e50933 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -37,25 +37,25 @@ class MigrateTests(MigrationTestBase): """ Tests basic usage of the migrate command. """ - # Make sure no tables are created + # No tables are created self.assertTableNotExists("migrations_author") self.assertTableNotExists("migrations_tribble") self.assertTableNotExists("migrations_book") # Run the migrations to 0001 only call_command("migrate", "migrations", "0001", verbosity=0) - # Make sure the right tables exist + # The correct tables exist self.assertTableExists("migrations_author") self.assertTableExists("migrations_tribble") self.assertTableNotExists("migrations_book") # Run migrations all the way call_command("migrate", verbosity=0) - # Make sure the right tables exist + # The correct tables exist self.assertTableExists("migrations_author") self.assertTableNotExists("migrations_tribble") self.assertTableExists("migrations_book") # Unmigrate everything call_command("migrate", "migrations", "zero", verbosity=0) - # Make sure it's all gone + # Tables are gone self.assertTableNotExists("migrations_author") self.assertTableNotExists("migrations_tribble") self.assertTableNotExists("migrations_book") @@ -194,7 +194,7 @@ class MigrateTests(MigrationTestBase): @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations_conflict"}) def test_migrate_conflict_exit(self): """ - Makes sure that migrate exits if it detects a conflict. + migrate exits if it detects a conflict. """ with self.assertRaisesMessage(CommandError, "Conflicting migrations detected"): call_command("migrate", "migrations") @@ -202,7 +202,8 @@ class MigrateTests(MigrationTestBase): @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) def test_showmigrations_list(self): """ - Tests --list output of showmigrations command + showmigrations --list displays migrations and whether or not they're + applied. """ out = six.StringIO() with mock.patch('django.core.management.color.supports_color', lambda *args: True): @@ -340,7 +341,7 @@ class MigrateTests(MigrationTestBase): @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) def test_sqlmigrate_forwards(self): """ - Makes sure that sqlmigrate does something. + sqlmigrate outputs forward looking SQL. """ out = six.StringIO() call_command("sqlmigrate", "migrations", "0001", stdout=out) @@ -378,7 +379,7 @@ class MigrateTests(MigrationTestBase): @override_settings(MIGRATION_MODULES={"migrations": "migrations.test_migrations"}) def test_sqlmigrate_backwards(self): """ - Makes sure that sqlmigrate does something. + sqlmigrate outputs reverse looking SQL. """ # Cannot generate the reverse SQL unless we've applied the migration. call_command("migrate", "migrations", verbosity=0) @@ -437,11 +438,11 @@ class MigrateTests(MigrationTestBase): INSTALLED_APPS=[ "migrations.migrations_test_apps.migrated_app", "migrations.migrations_test_apps.migrated_unapplied_app", - "migrations.migrations_test_apps.unmigrated_app"]) + "migrations.migrations_test_apps.unmigrated_app", + ], + ) def test_regression_22823_unmigrated_fk_to_migrated_model(self): """ - https://code.djangoproject.com/ticket/22823 - Assuming you have 3 apps, `A`, `B`, and `C`, such that: * `A` has migrations @@ -450,7 +451,7 @@ class MigrateTests(MigrationTestBase): When we try to migrate "B", an exception occurs because the "B" was not included in the ProjectState that is used to detect - soft-applied migrations. + soft-applied migrations (#22823). """ call_command("migrate", "migrated_unapplied_app", stdout=six.StringIO()) @@ -663,7 +664,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_conflict_exit(self): """ - Makes sure that makemigrations exits if it detects a conflict. + makemigrations exits if it detects a conflict. """ with self.temporary_migration_module(module="migrations.test_migrations_conflict"): with self.assertRaises(CommandError): @@ -671,7 +672,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_merge_no_conflict(self): """ - Makes sure that makemigrations exits if in merge mode with no conflicts. + makemigrations exits if in merge mode with no conflicts. """ out = six.StringIO() with self.temporary_migration_module(module="migrations.test_migrations"): @@ -680,7 +681,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_no_app_sys_exit(self): """ - Makes sure that makemigrations exits if a non-existent app is specified. + makemigrations exits if a non-existent app is specified. """ err = six.StringIO() with self.assertRaises(SystemExit): @@ -689,14 +690,14 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_empty_no_app_specified(self): """ - Makes sure that makemigrations exits if no app is specified with 'empty' mode. + makemigrations exits if no app is specified with 'empty' mode. """ with self.assertRaises(CommandError): call_command("makemigrations", empty=True) def test_makemigrations_empty_migration(self): """ - Makes sure that makemigrations properly constructs an empty migration. + makemigrations properly constructs an empty migration. """ with self.temporary_migration_module() as migration_dir: call_command("makemigrations", "migrations", empty=True, verbosity=0) @@ -729,7 +730,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_no_changes_no_apps(self): """ - Makes sure that makemigrations exits when there are no changes and no apps are specified. + makemigrations exits when there are no changes and no apps are specified. """ out = six.StringIO() call_command("makemigrations", stdout=out) @@ -737,7 +738,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_no_changes(self): """ - Makes sure that makemigrations exits when there are no changes to an app. + makemigrations exits when there are no changes to an app. """ out = six.StringIO() with self.temporary_migration_module(module="migrations.test_migrations_no_changes"): @@ -756,7 +757,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_migrations_announce(self): """ - Makes sure that makemigrations announces the migration at the default verbosity level. + makemigrations announces the migration at the default verbosity level. """ out = six.StringIO() with self.temporary_migration_module(): @@ -765,7 +766,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_no_common_ancestor(self): """ - Makes sure that makemigrations fails to merge migrations with no common ancestor. + makemigrations fails to merge migrations with no common ancestor. """ with self.assertRaises(ValueError) as context: with self.temporary_migration_module(module="migrations.test_migrations_no_ancestor"): @@ -777,7 +778,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_interactive_reject(self): """ - Makes sure that makemigrations enters and exits interactive mode properly. + makemigrations enters and exits interactive mode properly. """ # Monkeypatch interactive questioner to auto reject with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='N')): @@ -788,7 +789,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_interactive_accept(self): """ - Makes sure that makemigrations enters interactive mode and merges properly. + makemigrations enters interactive mode and merges properly. """ # Monkeypatch interactive questioner to auto accept with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='y')): @@ -812,7 +813,8 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_non_interactive_not_null_addition(self): """ - Tests that non-interactive makemigrations fails when a default is missing on a new not-null field. + Non-interactive makemigrations fails when a default is missing on a + new not-null field. """ class SillyModel(models.Model): silly_field = models.BooleanField(default=False) @@ -828,7 +830,8 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_non_interactive_not_null_alteration(self): """ - Tests that non-interactive makemigrations fails when a default is missing on a field changed to not-null. + Non-interactive makemigrations fails when a default is missing on a + field changed to not-null. """ class Author(models.Model): name = models.CharField(max_length=255) @@ -845,7 +848,8 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_non_interactive_no_model_rename(self): """ - Makes sure that makemigrations adds and removes a possible model rename in non-interactive mode. + makemigrations adds and removes a possible model rename in + non-interactive mode. """ class RenamedModel(models.Model): silly_field = models.BooleanField(default=False) @@ -861,7 +865,8 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_non_interactive_no_field_rename(self): """ - Makes sure that makemigrations adds and removes a possible field rename in non-interactive mode. + makemigrations adds and removes a possible field rename in + non-interactive mode. """ class SillyModel(models.Model): silly_rename = models.BooleanField(default=False) @@ -877,7 +882,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_handle_merge(self): """ - Makes sure that makemigrations properly merges the conflicting migrations with --noinput. + makemigrations properly merges the conflicting migrations with --noinput. """ out = six.StringIO() with self.temporary_migration_module(module="migrations.test_migrations_conflict") as migration_dir: @@ -892,8 +897,8 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigration_merge_dry_run(self): """ - Makes sure that makemigrations respects --dry-run option when fixing - migration conflicts (#24427). + makemigrations respects --dry-run option when fixing migration + conflicts (#24427). """ out = six.StringIO() with self.temporary_migration_module(module="migrations.test_migrations_conflict") as migration_dir: @@ -911,8 +916,8 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigration_merge_dry_run_verbosity_3(self): """ - Makes sure that `makemigrations --merge --dry-run` writes the merge - migration file to stdout with `verbosity == 3` (#24427). + `makemigrations --merge --dry-run` writes the merge migration file to + stdout with `verbosity == 3` (#24427). """ out = six.StringIO() with self.temporary_migration_module(module="migrations.test_migrations_conflict") as migration_dir: @@ -941,9 +946,8 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_dry_run(self): """ - Ticket #22676 -- `makemigrations --dry-run` should not ask for defaults. + `makemigrations --dry-run` should not ask for defaults. """ - class SillyModel(models.Model): silly_field = models.BooleanField(default=False) silly_date = models.DateField() # Added field without a default @@ -959,10 +963,9 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_dry_run_verbosity_3(self): """ - Ticket #22675 -- Allow `makemigrations --dry-run` to output the - migrations file to stdout (with verbosity == 3). + Allow `makemigrations --dry-run` to output the migrations file to + stdout (with verbosity == 3). """ - class SillyModel(models.Model): silly_field = models.BooleanField(default=False) silly_char = models.CharField(default="") @@ -989,11 +992,10 @@ class MakeMigrationsTests(MigrationTestBase): 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 + makemigrations creates migrations when specifying a 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) @@ -1014,9 +1016,9 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_interactive_by_default(self): """ - Makes sure that the user is prompted to merge by default if there are - conflicts and merge is True. Answer negative to differentiate it from - behavior when --noinput is specified. + The user is prompted to merge by default if there are conflicts and + merge is True. Answer negative to differentiate it from behavior when + --noinput is specified. """ # Monkeypatch interactive questioner to auto reject out = six.StringIO() @@ -1034,8 +1036,8 @@ class MakeMigrationsTests(MigrationTestBase): "migrations.migrations_test_apps.unspecified_app_with_conflict"]) def test_makemigrations_unspecified_app_with_conflict_no_merge(self): """ - Makes sure that makemigrations does not raise a CommandError when an - unspecified app has conflicting migrations. + makemigrations does not raise a CommandError when an unspecified app + has conflicting migrations. """ with self.temporary_migration_module(module="migrations.test_migrations_no_changes"): call_command("makemigrations", "migrations", merge=False, verbosity=0) @@ -1046,8 +1048,8 @@ class MakeMigrationsTests(MigrationTestBase): "migrations.migrations_test_apps.unspecified_app_with_conflict"]) def test_makemigrations_unspecified_app_with_conflict_merge(self): """ - Makes sure that makemigrations does not create a merge for an - unspecified app even if it has conflicting migrations. + makemigrations does not create a merge for an unspecified app even if + it has conflicting migrations. """ # Monkeypatch interactive questioner to auto accept with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='y')): @@ -1064,8 +1066,8 @@ class MakeMigrationsTests(MigrationTestBase): "migrations.migrations_test_apps.conflicting_app_with_dependencies"]) def test_makemigrations_merge_dont_output_dependency_operations(self): """ - Makes sure that makemigrations --merge does not output any operations - from apps that don't belong to a given app. + makemigrations --merge does not output any operations from apps that + don't belong to a given app. """ # Monkeypatch interactive questioner to auto accept with mock.patch('django.db.migrations.questioner.input', mock.Mock(return_value='N')): @@ -1093,7 +1095,7 @@ class MakeMigrationsTests(MigrationTestBase): def test_makemigrations_with_custom_name(self): """ - Makes sure that makemigrations generate a custom migration. + makemigrations --name generate a custom migration name. """ with self.temporary_migration_module() as migration_dir: @@ -1218,7 +1220,7 @@ class SquashMigrationsTests(MigrationTestBase): def test_squashmigrations_squashes(self): """ - Tests that squashmigrations squashes migrations. + squashmigrations squashes migrations. """ with self.temporary_migration_module(module="migrations.test_migrations") as migration_dir: call_command("squashmigrations", "migrations", "0002", interactive=False, verbosity=0) @@ -1237,7 +1239,7 @@ class SquashMigrationsTests(MigrationTestBase): def test_squashmigrations_optimizes(self): """ - Tests that squashmigrations optimizes operations. + squashmigrations optimizes operations. """ out = six.StringIO() with self.temporary_migration_module(module="migrations.test_migrations"): @@ -1246,7 +1248,7 @@ class SquashMigrationsTests(MigrationTestBase): def test_ticket_23799_squashmigrations_no_optimize(self): """ - Makes sure that squashmigrations --no-optimize really doesn't optimize operations. + squashmigrations --no-optimize doesn't optimize operations. """ out = six.StringIO() with self.temporary_migration_module(module="migrations.test_migrations"): diff --git a/tests/migrations/test_executor.py b/tests/migrations/test_executor.py index 93651d74bc..01b31a6dae 100644 --- a/tests/migrations/test_executor.py +++ b/tests/migrations/test_executor.py @@ -133,7 +133,7 @@ class ExecutorTests(MigrationTestBase): }) def test_empty_plan(self): """ - Tests that re-planning a full migration of a fully-migrated set doesn't + Re-planning a full migration of a fully-migrated set doesn't perform spurious unmigrations and remigrations. There was previously a bug where the executor just always performed the @@ -404,7 +404,7 @@ class ExecutorTests(MigrationTestBase): ) def test_unrelated_model_lookups_forwards(self): """ - #24123 - Tests that all models of apps already applied which are + #24123 - All models of apps already applied which are unrelated to the first app being applied are part of the initial model state. """ @@ -449,7 +449,7 @@ class ExecutorTests(MigrationTestBase): ) def test_unrelated_model_lookups_backwards(self): """ - #24123 - Tests that all models of apps being unapplied which are + #24123 - All models of apps being unapplied which are unrelated to the first app being unapplied are part of the initial model state. """ diff --git a/tests/migrations/test_graph.py b/tests/migrations/test_graph.py index ad7e04581c..26a5f18328 100644 --- a/tests/migrations/test_graph.py +++ b/tests/migrations/test_graph.py @@ -285,7 +285,7 @@ class GraphTests(SimpleTestCase): def test_remove_replaced_nodes(self): """ - Tests that replaced nodes are properly removed and dependencies remapped. + Replaced nodes are properly removed and dependencies remapped. """ # Add some dummy nodes to be replaced. graph = MigrationGraph() @@ -328,7 +328,7 @@ class GraphTests(SimpleTestCase): def test_remove_replacement_node(self): """ - Tests that a replacement node is properly removed and child dependencies remapped. + A replacement node is properly removed and child dependencies remapped. We assume parent dependencies are already correct. """ # Add some dummy nodes to be replaced. diff --git a/tests/migrations/test_multidb.py b/tests/migrations/test_multidb.py index 0d7ea92ef5..c6ca4a844e 100644 --- a/tests/migrations/test_multidb.py +++ b/tests/migrations/test_multidb.py @@ -49,7 +49,7 @@ class MultiDBOperationTests(OperationTestBase): def _test_create_model(self, app_label, should_run): """ - Tests that CreateModel honours multi-db settings. + CreateModel honors multi-db settings. """ operation = migrations.CreateModel( "Pony", diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index cab0caf75a..8a7ccbffc2 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -402,7 +402,7 @@ class OperationTests(OperationTestBase): def test_create_proxy_model(self): """ - Tests that CreateModel ignores proxy models. + CreateModel ignores proxy models. """ project_state = self.set_up_test_model("test_crprmo") # Test the state alteration @@ -436,7 +436,7 @@ class OperationTests(OperationTestBase): def test_create_unmanaged_model(self): """ - Tests that CreateModel ignores unmanaged models. + CreateModel ignores unmanaged models. """ project_state = self.set_up_test_model("test_crummo") # Test the state alteration @@ -465,7 +465,7 @@ class OperationTests(OperationTestBase): def test_create_model_managers(self): """ - Tests that the managers on a model are set. + The managers on a model are set. """ project_state = self.set_up_test_model("test_cmoma") # Test the state alteration @@ -1502,7 +1502,7 @@ class OperationTests(OperationTestBase): self.assertColumnNotNull("test_alflin_pony", "pink") with connection.schema_editor() as editor: operation.database_forwards("test_alflin", editor, project_state, new_state) - # Ensure that index hasn't been dropped + # Index hasn't been dropped self.assertIndexExists("test_alflin_pony", ["pink"]) # And test reversal with connection.schema_editor() as editor: @@ -1563,7 +1563,7 @@ class OperationTests(OperationTestBase): def test_alter_model_options_emptying(self): """ - Tests that the AlterModelOptions operation removes keys from the dict (#23121) + The AlterModelOptions operation removes keys from the dict (#23121) """ project_state = self.set_up_test_model("test_almoop", options=True) # Test the state alteration (no DB alteration to test) @@ -1623,7 +1623,7 @@ class OperationTests(OperationTestBase): def test_alter_model_managers(self): """ - Tests that the managers on a model are set. + The managers on a model are set. """ project_state = self.set_up_test_model("test_almoma") # Test the state alteration @@ -1659,7 +1659,7 @@ class OperationTests(OperationTestBase): def test_alter_model_managers_emptying(self): """ - Tests that the managers on a model are set. + The managers on a model are set. """ project_state = self.set_up_test_model("test_almomae", manager_model=True) # Test the state alteration @@ -1683,7 +1683,7 @@ class OperationTests(OperationTestBase): def test_alter_fk(self): """ - Tests that creating and then altering an FK works correctly + Creating and then altering an FK works correctly and deals with the pending SQL (#23091) """ project_state = self.set_up_test_model("test_alfk") @@ -1710,7 +1710,7 @@ class OperationTests(OperationTestBase): def test_alter_fk_non_fk(self): """ - Tests that altering an FK to a non-FK works (#23244) + Altering an FK to a non-FK works (#23244) """ # Test the state alteration operation = migrations.AlterField( @@ -2013,7 +2013,7 @@ class OperationTests(OperationTestBase): def test_run_python_related_assignment(self): """ - #24282 - Tests that model changes to a FK reverse side update the model + #24282 - Model changes to a FK reverse side update the model on the FK side as well. """ @@ -2307,7 +2307,7 @@ class OperationTests(OperationTestBase): operation.state_forwards(app_label, new_state) def assertModelsAndTables(after_db): - # Check that tables and models exist, or don't, as they should: + # Tables and models exist, or don't, as they should: self.assertNotIn((app_label, "somethingelse"), new_state.models) self.assertEqual(len(new_state.models[app_label, "somethingcompletelydifferent"].fields), 1) self.assertNotIn((app_label, "iloveponiesonies"), new_state.models) @@ -2337,7 +2337,7 @@ class OperationTests(OperationTestBase): class SwappableOperationTests(OperationTestBase): """ - Tests that key operations ignore swappable models + Key operations ignore swappable models (we don't want to replicate all of them here, as the functionality is in a common base class anyway) """ @@ -2351,7 +2351,7 @@ class SwappableOperationTests(OperationTestBase): @override_settings(TEST_SWAP_MODEL="migrations.SomeFakeModel") def test_create_ignore_swapped(self): """ - Tests that the CreateTable operation ignores swapped models. + The CreateTable operation ignores swapped models. """ operation = migrations.CreateModel( "Pony", diff --git a/tests/migrations/test_optimizer.py b/tests/migrations/test_optimizer.py index 6bf09d0178..4893bf0caa 100644 --- a/tests/migrations/test_optimizer.py +++ b/tests/migrations/test_optimizer.py @@ -39,7 +39,7 @@ class OptimizerTests(SimpleTestCase): def test_single(self): """ - Tests that the optimizer does nothing on a single operation, + The optimizer does nothing on a single operation, and that it does it in just one pass. """ self.assertOptimizesTo( @@ -655,9 +655,9 @@ class OptimizerTests(SimpleTestCase): def test_optimize_through_fields(self): """ - Checks that field-level through checking is working. - This should manage to collapse model Foo to nonexistence, - and model Bar to a single IntegerField called "width". + field-level through checking is working. This should manage to collapse + model Foo to nonexistence, and model Bar to a single IntegerField + called "width". """ self.assertOptimizesTo( [ diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py index 9428ea060d..c8eb1726ba 100644 --- a/tests/migrations/test_state.py +++ b/tests/migrations/test_state.py @@ -447,7 +447,7 @@ class StateTests(SimpleTestCase): def test_render_project_dependencies(self): """ - Tests that the ProjectState render method correctly renders models + The ProjectState render method correctly renders models to account for inter-model base dependencies. """ new_apps = Apps() @@ -506,7 +506,7 @@ class StateTests(SimpleTestCase): def test_render_unique_app_labels(self): """ - Tests that the ProjectState render method doesn't raise an + The ProjectState render method doesn't raise an ImproperlyConfigured exception about unique labels if two dotted app names have the same last part. """ @@ -557,7 +557,7 @@ class StateTests(SimpleTestCase): model_a_old = old_state.apps.get_model('something', 'A') model_b_old = old_state.apps.get_model('something', 'B') model_c_old = old_state.apps.get_model('something', 'C') - # Check that the relations between the old models are correct + # The relations between the old models are correct self.assertIs(model_a_old._meta.get_field('b').related_model, model_b_old) self.assertIs(model_b_old._meta.get_field('a_ptr').related_model, model_a_old) @@ -571,14 +571,14 @@ class StateTests(SimpleTestCase): model_b_new = project_state.apps.get_model('something', 'B') model_c_new = project_state.apps.get_model('something', 'C') - # Check that all models have changed + # All models have changed self.assertIsNot(model_a_old, model_a_new) self.assertIsNot(model_b_old, model_b_new) self.assertIsNot(model_c_old, model_c_new) - # Check that the relations between the old models still hold + # The relations between the old models still hold self.assertIs(model_a_old._meta.get_field('b').related_model, model_b_old) self.assertIs(model_b_old._meta.get_field('a_ptr').related_model, model_a_old) - # Check that the relations between the new models correct + # The relations between the new models correct self.assertIs(model_a_new._meta.get_field('b').related_model, model_b_new) self.assertIs(model_b_new._meta.get_field('a_ptr').related_model, model_a_new) self.assertIs(model_a_new._meta.get_field('from_c').related_model, model_c_new) @@ -586,7 +586,7 @@ class StateTests(SimpleTestCase): def test_remove_relations(self): """ - #24225 - Tests that relations between models are updated while + #24225 - Relations between models are updated while remaining the relations and references for models of an old state. """ new_apps = Apps() @@ -614,7 +614,7 @@ class StateTests(SimpleTestCase): operation = RemoveField("b", "to_a") operation.state_forwards("something", project_state) - # Tests that model from old_state still has the relation + # Model from old_state still has the relation model_a_old = get_model_a(old_state) model_a_new = get_model_a(project_state) self.assertIsNot(model_a_old, model_a_new) @@ -668,7 +668,7 @@ class StateTests(SimpleTestCase): model_a_new = get_model_a(project_state) self.assertIsNot(model_a_old, model_a_new) - # Tests that the old model's _meta is still consistent + # The old model's _meta is still consistent field_to_a_old = model_a_old._meta.get_field("to_a") self.assertEqual(field_to_a_old.m2m_field_name(), "from_a") self.assertEqual(field_to_a_old.m2m_reverse_field_name(), "to_a") @@ -676,7 +676,7 @@ class StateTests(SimpleTestCase): self.assertIs(field_to_a_old.remote_field.through._meta.get_field('to_a').related_model, model_a_old) self.assertIs(field_to_a_old.remote_field.through._meta.get_field('from_a').related_model, model_a_old) - # Tests that the new model's _meta is still consistent + # The new model's _meta is still consistent field_to_a_new = model_a_new._meta.get_field("to_a") self.assertEqual(field_to_a_new.m2m_field_name(), "from_a") self.assertEqual(field_to_a_new.m2m_reverse_field_name(), "to_a") @@ -686,9 +686,8 @@ class StateTests(SimpleTestCase): def test_equality(self): """ - Tests that == and != are implemented correctly. + == and != are implemented correctly. """ - # Test two things that should be equal project_state = ProjectState() project_state.add_model(ModelState( @@ -807,7 +806,7 @@ class StateTests(SimpleTestCase): def test_real_apps(self): """ - Tests that including real apps can resolve dangling FK errors. + Including real apps can resolve dangling FK errors. This test relies on the fact that contenttypes is always loaded. """ new_apps = Apps() @@ -867,7 +866,7 @@ class StateTests(SimpleTestCase): def test_manager_refer_correct_model_version(self): """ - #24147 - Tests that managers refer to the correct version of a + #24147 - Managers refer to the correct version of a historical model """ project_state = ProjectState() @@ -962,7 +961,7 @@ class ModelStateTests(SimpleTestCase): def test_fields_immutability(self): """ - Tests that rendering a model state doesn't alter its internal fields. + Rendering a model state doesn't alter its internal fields. """ apps = Apps() field = models.CharField(max_length=1) |
