Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings.

This commit is contained in:
za 2016-10-27 14:53:39 +07:00 committed by Tim Graham
parent 4bb70cbcc6
commit 321e94fa41
185 changed files with 1216 additions and 1528 deletions

View file

@ -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"):