summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-11-25 12:29:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-11-26 09:18:00 -0500
commit3b09a89d95f765399324dd53b4cb8504b0a7903b (patch)
treedc0837c10c7f0374c14ae4f267598f0060dfaddd /tests
parentfc451e60731ad5b8d73255f0a1996e1d4e0f20de (diff)
downloadalembic-3b09a89d95f765399324dd53b4cb8504b0a7903b.tar.gz
run pyupgrade
command is: find alembic -name "*.py" | xargs pyupgrade --py37-plus --keep-runtime-typing --keep-percent-format I'm having some weird fighting with the tools/write_pyi, where in different runtime contexts it keeps losing "MigrationContext" and also Callable drops the args, but it's not consisistent. For whatever reason, under py311 things *do* work every time. im working w/ clean tox environments so not really sure what the change is. anyway, let's at least fix the quoting up around the types. This is towards getting the "*" in the op signatures for #1130. Change-Id: I9175905d3b4325e03a97d6752356b70be20e9fad
Diffstat (limited to 'tests')
-rw-r--r--tests/test_autogen_composition.py10
-rw-r--r--tests/test_autogen_diffs.py28
-rw-r--r--tests/test_autogen_indexes.py38
-rw-r--r--tests/test_autogen_render.py4
-rw-r--r--tests/test_batch.py46
-rw-r--r--tests/test_command.py16
-rw-r--r--tests/test_config.py1
-rw-r--r--tests/test_environment.py1
-rw-r--r--tests/test_external_dialect.py32
-rw-r--r--tests/test_postgresql.py8
-rw-r--r--tests/test_script_consumption.py6
-rw-r--r--tests/test_script_production.py13
-rw-r--r--tests/test_version_traversal.py162
13 files changed, 161 insertions, 204 deletions
diff --git a/tests/test_autogen_composition.py b/tests/test_autogen_composition.py
index acd3603..99e5486 100644
--- a/tests/test_autogen_composition.py
+++ b/tests/test_autogen_composition.py
@@ -243,12 +243,10 @@ nullable=True))
autogenerate._render_migration_diffs(self.context, template_args)
eq_(
set(template_args["imports"].split("\n")),
- set(
- [
- "from foobar import bat",
- "from mypackage import my_special_import",
- ]
- ),
+ {
+ "from foobar import bat",
+ "from mypackage import my_special_import",
+ },
)
diff --git a/tests/test_autogen_diffs.py b/tests/test_autogen_diffs.py
index ead1a7c..86b2460 100644
--- a/tests/test_autogen_diffs.py
+++ b/tests/test_autogen_diffs.py
@@ -289,7 +289,7 @@ class AutogenDefaultSchemaIsNoneTest(AutogenFixtureTest, TestBase):
__only_on__ = "sqlite"
def setUp(self):
- super(AutogenDefaultSchemaIsNoneTest, self).setUp()
+ super().setUp()
# in SQLAlchemy 1.4, SQLite dialect is setting this name
# to "main" as is the actual default schema name for SQLite.
@@ -512,13 +512,11 @@ class AutogenerateDiffTest(ModelOne, AutogenTest, TestBase):
)
alter_cols = (
- set(
- [
- d[2]
- for d in self._flatten_diffs(diffs)
- if d[0].startswith("modify")
- ]
- )
+ {
+ d[2]
+ for d in self._flatten_diffs(diffs)
+ if d[0].startswith("modify")
+ }
.union(
d[3].name
for d in self._flatten_diffs(diffs)
@@ -530,7 +528,7 @@ class AutogenerateDiffTest(ModelOne, AutogenTest, TestBase):
if d[0] == "add_table"
)
)
- eq_(alter_cols, set(["user_id", "order", "user"]))
+ eq_(alter_cols, {"user_id", "order", "user"})
def test_include_name(self):
all_names = set()
@@ -582,13 +580,11 @@ class AutogenerateDiffTest(ModelOne, AutogenTest, TestBase):
)
alter_cols = (
- set(
- [
- d[2]
- for d in self._flatten_diffs(diffs)
- if d[0].startswith("modify")
- ]
- )
+ {
+ d[2]
+ for d in self._flatten_diffs(diffs)
+ if d[0].startswith("modify")
+ }
.union(
d[3].name
for d in self._flatten_diffs(diffs)
diff --git a/tests/test_autogen_indexes.py b/tests/test_autogen_indexes.py
index fb71099..68a6bd6 100644
--- a/tests/test_autogen_indexes.py
+++ b/tests/test_autogen_indexes.py
@@ -552,7 +552,7 @@ class AutogenerateUniqueIndexTest(AutogenFixtureTest, TestBase):
diffs = self._fixture(m1, m2)
- diffs = set(
+ diffs = {
(
cmd,
isinstance(obj, (UniqueConstraint, Index))
@@ -560,23 +560,21 @@ class AutogenerateUniqueIndexTest(AutogenFixtureTest, TestBase):
else False,
)
for cmd, obj in diffs
- )
+ }
if self.reports_unnamed_constraints:
if self.reports_unique_constraints_as_indexes:
eq_(
diffs,
- set([("remove_index", True), ("add_constraint", False)]),
+ {("remove_index", True), ("add_constraint", False)},
)
else:
eq_(
diffs,
- set(
- [
- ("remove_constraint", True),
- ("add_constraint", False),
- ]
- ),
+ {
+ ("remove_constraint", True),
+ ("add_constraint", False),
+ },
)
def test_remove_named_unique_index(self):
@@ -594,8 +592,8 @@ class AutogenerateUniqueIndexTest(AutogenFixtureTest, TestBase):
diffs = self._fixture(m1, m2)
if self.reports_unique_constraints:
- diffs = set((cmd, obj.name) for cmd, obj in diffs)
- eq_(diffs, set([("remove_index", "xidx")]))
+ diffs = {(cmd, obj.name) for cmd, obj in diffs}
+ eq_(diffs, {("remove_index", "xidx")})
else:
eq_(diffs, [])
@@ -614,11 +612,11 @@ class AutogenerateUniqueIndexTest(AutogenFixtureTest, TestBase):
diffs = self._fixture(m1, m2)
if self.reports_unique_constraints:
- diffs = set((cmd, obj.name) for cmd, obj in diffs)
+ diffs = {(cmd, obj.name) for cmd, obj in diffs}
if self.reports_unique_constraints_as_indexes:
- eq_(diffs, set([("remove_index", "xidx")]))
+ eq_(diffs, {("remove_index", "xidx")})
else:
- eq_(diffs, set([("remove_constraint", "xidx")]))
+ eq_(diffs, {("remove_constraint", "xidx")})
else:
eq_(diffs, [])
@@ -668,9 +666,9 @@ class AutogenerateUniqueIndexTest(AutogenFixtureTest, TestBase):
eq_(diffs[0][0], "add_table")
eq_(len(diffs), 2)
- assert UniqueConstraint not in set(
+ assert UniqueConstraint not in {
type(c) for c in diffs[0][1].constraints
- )
+ }
eq_(diffs[1][0], "add_index")
d_table = diffs[0][1]
@@ -1071,9 +1069,7 @@ class AutogenerateIndexTest(AutogenFixtureTest, TestBase):
eq_(diffs[1][0], "remove_index")
eq_(diffs[2][0], "remove_table")
- eq_(
- set([diffs[0][1].name, diffs[1][1].name]), set(["xy_idx", "y_idx"])
- )
+ eq_({diffs[0][1].name, diffs[1][1].name}, {"xy_idx", "y_idx"})
def test_add_ix_on_table_create(self):
m1 = MetaData()
@@ -1083,9 +1079,9 @@ class AutogenerateIndexTest(AutogenFixtureTest, TestBase):
eq_(diffs[0][0], "add_table")
eq_(len(diffs), 2)
- assert UniqueConstraint not in set(
+ assert UniqueConstraint not in {
type(c) for c in diffs[0][1].constraints
- )
+ }
eq_(diffs[1][0], "add_index")
eq_(diffs[1][1].unique, False)
diff --git a/tests/test_autogen_render.py b/tests/test_autogen_render.py
index 6709328..0a2fc87 100644
--- a/tests/test_autogen_render.py
+++ b/tests/test_autogen_render.py
@@ -1296,7 +1296,7 @@ class AutogenRenderTest(TestBase):
)
eq_(
self.autogen_context.imports,
- set(["from mypackage import MySpecialType"]),
+ {"from mypackage import MySpecialType"},
)
def test_render_modify_type(self):
@@ -1833,7 +1833,7 @@ class AutogenRenderTest(TestBase):
)
eq_(
self.autogen_context.imports,
- set(["from sqlalchemy.dialects import mysql"]),
+ {"from sqlalchemy.dialects import mysql"},
)
def test_render_server_default_text(self):
diff --git a/tests/test_batch.py b/tests/test_batch.py
index 2d29f6c..e0289aa 100644
--- a/tests/test_batch.py
+++ b/tests/test_batch.py
@@ -1553,11 +1553,11 @@ class BatchRoundTripTest(TestBase):
insp = inspect(self.conn)
eq_(
- set(
+ {
(ix["name"], tuple(ix["column_names"]))
for ix in insp.get_indexes("t_w_ix")
- ),
- set([("ix_data", ("data",)), ("ix_thing", ("thing",))]),
+ },
+ {("ix_data", ("data",)), ("ix_thing", ("thing",))},
)
def test_fk_points_to_me_auto(self):
@@ -2268,39 +2268,37 @@ class BatchRoundTripMySQLTest(BatchRoundTripTest):
@exclusions.fails()
def test_drop_pk_col_readd_pk_col(self):
- super(BatchRoundTripMySQLTest, self).test_drop_pk_col_readd_pk_col()
+ super().test_drop_pk_col_readd_pk_col()
@exclusions.fails()
def test_drop_pk_col_readd_col_also_pk_const(self):
- super(
- BatchRoundTripMySQLTest, self
- ).test_drop_pk_col_readd_col_also_pk_const()
+ super().test_drop_pk_col_readd_col_also_pk_const()
@exclusions.fails()
def test_rename_column_pk(self):
- super(BatchRoundTripMySQLTest, self).test_rename_column_pk()
+ super().test_rename_column_pk()
@exclusions.fails()
def test_rename_column(self):
- super(BatchRoundTripMySQLTest, self).test_rename_column()
+ super().test_rename_column()
@exclusions.fails()
def test_change_type(self):
- super(BatchRoundTripMySQLTest, self).test_change_type()
+ super().test_change_type()
def test_create_drop_index(self):
- super(BatchRoundTripMySQLTest, self).test_create_drop_index()
+ super().test_create_drop_index()
# fails on mariadb 10.2, succeeds on 10.3
@exclusions.fails_if(config.requirements.mysql_check_col_name_change)
def test_rename_column_boolean(self):
- super(BatchRoundTripMySQLTest, self).test_rename_column_boolean()
+ super().test_rename_column_boolean()
def test_change_type_boolean_to_int(self):
- super(BatchRoundTripMySQLTest, self).test_change_type_boolean_to_int()
+ super().test_change_type_boolean_to_int()
def test_change_type_int_to_boolean(self):
- super(BatchRoundTripMySQLTest, self).test_change_type_int_to_boolean()
+ super().test_change_type_int_to_boolean()
class BatchRoundTripPostgresqlTest(BatchRoundTripTest):
@@ -2327,34 +2325,26 @@ class BatchRoundTripPostgresqlTest(BatchRoundTripTest):
@exclusions.fails()
def test_drop_pk_col_readd_pk_col(self):
- super(
- BatchRoundTripPostgresqlTest, self
- ).test_drop_pk_col_readd_pk_col()
+ super().test_drop_pk_col_readd_pk_col()
@exclusions.fails()
def test_drop_pk_col_readd_col_also_pk_const(self):
- super(
- BatchRoundTripPostgresqlTest, self
- ).test_drop_pk_col_readd_col_also_pk_const()
+ super().test_drop_pk_col_readd_col_also_pk_const()
@exclusions.fails()
def test_change_type(self):
- super(BatchRoundTripPostgresqlTest, self).test_change_type()
+ super().test_change_type()
def test_create_drop_index(self):
- super(BatchRoundTripPostgresqlTest, self).test_create_drop_index()
+ super().test_create_drop_index()
@exclusions.fails()
def test_change_type_int_to_boolean(self):
- super(
- BatchRoundTripPostgresqlTest, self
- ).test_change_type_int_to_boolean()
+ super().test_change_type_int_to_boolean()
@exclusions.fails()
def test_change_type_boolean_to_int(self):
- super(
- BatchRoundTripPostgresqlTest, self
- ).test_change_type_boolean_to_int()
+ super().test_change_type_boolean_to_int()
def test_add_col_table_has_native_boolean(self):
self._native_boolean_fixture()
diff --git a/tests/test_command.py b/tests/test_command.py
index 0c0ce37..e136c4e 100644
--- a/tests/test_command.py
+++ b/tests/test_command.py
@@ -224,15 +224,13 @@ class CurrentTest(_BufMixin, TestBase):
yield
- lines = set(
- [
- re.match(r"(^.\w)", elem).group(1)
- for elem in re.split(
- "\n", buf.getvalue().decode("ascii", "replace").strip()
- )
- if elem
- ]
- )
+ lines = {
+ re.match(r"(^.\w)", elem).group(1)
+ for elem in re.split(
+ "\n", buf.getvalue().decode("ascii", "replace").strip()
+ )
+ if elem
+ }
eq_(lines, set(revs))
diff --git a/tests/test_config.py b/tests/test_config.py
index 7957a1b..9f3929a 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -1,4 +1,3 @@
-#!coding: utf-8
import os
import tempfile
diff --git a/tests/test_environment.py b/tests/test_environment.py
index d6c3a65..d9c14ca 100644
--- a/tests/test_environment.py
+++ b/tests/test_environment.py
@@ -1,4 +1,3 @@
-#!coding: utf-8
import os
import sys
diff --git a/tests/test_external_dialect.py b/tests/test_external_dialect.py
index 9ddc12f..de66517 100644
--- a/tests/test_external_dialect.py
+++ b/tests/test_external_dialect.py
@@ -65,7 +65,7 @@ class EXT_ARRAY(sqla_types.TypeEngine):
if isinstance(item_type, type):
item_type = item_type()
self.item_type = item_type
- super(EXT_ARRAY, self).__init__()
+ super().__init__()
class FOOBARTYPE(sqla_types.TypeEngine):
@@ -94,12 +94,10 @@ class ExternalDialectRenderTest(TestBase):
eq_(
self.autogen_context.imports,
- set(
- [
- "from tests.test_external_dialect "
- "import custom_dialect_types"
- ]
- ),
+ {
+ "from tests.test_external_dialect "
+ "import custom_dialect_types"
+ },
)
def test_external_nested_render_sqla_type(self):
@@ -121,12 +119,10 @@ class ExternalDialectRenderTest(TestBase):
eq_(
self.autogen_context.imports,
- set(
- [
- "from tests.test_external_dialect "
- "import custom_dialect_types"
- ]
- ),
+ {
+ "from tests.test_external_dialect "
+ "import custom_dialect_types"
+ },
)
def test_external_nested_render_external_type(self):
@@ -141,10 +137,8 @@ class ExternalDialectRenderTest(TestBase):
eq_(
self.autogen_context.imports,
- set(
- [
- "from tests.test_external_dialect "
- "import custom_dialect_types"
- ]
- ),
+ {
+ "from tests.test_external_dialect "
+ "import custom_dialect_types"
+ },
)
diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py
index b9be5cb..6a67e0b 100644
--- a/tests/test_postgresql.py
+++ b/tests/test_postgresql.py
@@ -838,9 +838,7 @@ class PostgresqlDetectSerialTest(TestBase):
insp = inspect(config.db)
uo = ops.UpgradeOps(ops=[])
- _compare_tables(
- set([(None, "t")]), set([]), insp, uo, self.autogen_context
- )
+ _compare_tables({(None, "t")}, set(), insp, uo, self.autogen_context)
diffs = uo.as_diffs()
tab = diffs[0][1]
@@ -857,8 +855,8 @@ class PostgresqlDetectSerialTest(TestBase):
Table("t", m2, Column("x", BigInteger()))
self.autogen_context.metadata = m2
_compare_tables(
- set([(None, "t")]),
- set([(None, "t")]),
+ {(None, "t")},
+ {(None, "t")},
insp,
uo,
self.autogen_context,
diff --git a/tests/test_script_consumption.py b/tests/test_script_consumption.py
index d478ae1..fa84d7e 100644
--- a/tests/test_script_consumption.py
+++ b/tests/test_script_consumption.py
@@ -1,5 +1,3 @@
-# coding: utf-8
-
from contextlib import contextmanager
import os
import re
@@ -369,7 +367,7 @@ class CallbackEnvironmentTest(ApplyVersionsFunctionalTest):
alembic.mock_event_listener = None
self._env_file_fixture()
with mock.patch("alembic.mock_event_listener", mock.Mock()) as mymock:
- super(CallbackEnvironmentTest, self).test_steps()
+ super().test_steps()
calls = mymock.call_args_list
assert calls
for call in calls:
@@ -682,7 +680,7 @@ def downgrade():
bytes_io=True, output_encoding="utf-8"
) as buf:
command.upgrade(self.cfg, self.a, sql=True)
- assert "« S’il vous plaît…".encode("utf-8") in buf.getvalue()
+ assert "« S’il vous plaît…".encode() in buf.getvalue()
class VersionNameTemplateTest(TestBase):
diff --git a/tests/test_script_production.py b/tests/test_script_production.py
index 2cf9052..bedf545 100644
--- a/tests/test_script_production.py
+++ b/tests/test_script_production.py
@@ -1,6 +1,7 @@
import datetime
import os
import re
+from unittest.mock import patch
from dateutil import tz
import sqlalchemy as sa
@@ -36,10 +37,6 @@ from alembic.testing.env import write_script
from alembic.testing.fixtures import TestBase
from alembic.util import CommandError
-try:
- from unittest.mock import patch
-except ImportError:
- from mock import patch # noqa
env, abc, def_ = None, None, None
@@ -62,7 +59,7 @@ class GeneralOrderedTests(TestBase):
self._test_008_long_name_configurable()
def _test_001_environment(self):
- assert_set = set(["env.py", "script.py.mako", "README"])
+ assert_set = {"env.py", "script.py.mako", "README"}
eq_(assert_set.intersection(os.listdir(env.dir)), assert_set)
def _test_002_rev_ids(self):
@@ -101,7 +98,7 @@ class GeneralOrderedTests(TestBase):
)
eq_(script.revision, def_)
eq_(script.down_revision, abc)
- eq_(env.get_revision(abc).nextrev, set([def_]))
+ eq_(env.get_revision(abc).nextrev, {def_})
assert script.module.down_revision == abc
assert callable(script.module.upgrade)
assert callable(script.module.downgrade)
@@ -115,7 +112,7 @@ class GeneralOrderedTests(TestBase):
env = staging_env(create=False)
abc_rev = env.get_revision(abc)
def_rev = env.get_revision(def_)
- eq_(abc_rev.nextrev, set([def_]))
+ eq_(abc_rev.nextrev, {def_})
eq_(abc_rev.revision, abc)
eq_(def_rev.down_revision, abc)
eq_(env.get_heads(), [def_])
@@ -319,7 +316,7 @@ class RevisionCommandTest(TestBase):
rev = script.get_revision(rev.revision)
eq_(rev.down_revision, self.b)
assert "some message" in rev.doc
- eq_(set(script.get_heads()), set([rev.revision, self.c]))
+ eq_(set(script.get_heads()), {rev.revision, self.c})
def test_create_script_missing_splice(self):
assert_raises_message(
diff --git a/tests/test_version_traversal.py b/tests/test_version_traversal.py
index 92413ac..f7ad4f0 100644
--- a/tests/test_version_traversal.py
+++ b/tests/test_version_traversal.py
@@ -75,14 +75,14 @@ class RevisionPathTest(MigrationTest):
self.e.revision,
self.c.revision,
[self.up_(self.d), self.up_(self.e)],
- set([self.e.revision]),
+ {self.e.revision},
)
self._assert_upgrade(
self.c.revision,
None,
[self.up_(self.a), self.up_(self.b), self.up_(self.c)],
- set([self.c.revision]),
+ {self.c.revision},
)
def test_relative_upgrade_path(self):
@@ -90,32 +90,32 @@ class RevisionPathTest(MigrationTest):
"+2",
self.a.revision,
[self.up_(self.b), self.up_(self.c)],
- set([self.c.revision]),
+ {self.c.revision},
)
self._assert_upgrade(
- "+1", self.a.revision, [self.up_(self.b)], set([self.b.revision])
+ "+1", self.a.revision, [self.up_(self.b)], {self.b.revision}
)
self._assert_upgrade(
"+3",
self.b.revision,
[self.up_(self.c), self.up_(self.d), self.up_(self.e)],
- set([self.e.revision]),
+ {self.e.revision},
)
self._assert_upgrade(
"%s+2" % self.b.revision,
self.a.revision,
[self.up_(self.b), self.up_(self.c), self.up_(self.d)],
- set([self.d.revision]),
+ {self.d.revision},
)
self._assert_upgrade(
"%s-2" % self.d.revision,
self.a.revision,
[self.up_(self.b)],
- set([self.b.revision]),
+ {self.b.revision},
)
def test_invalid_relative_upgrade_path(self):
@@ -142,7 +142,7 @@ class RevisionPathTest(MigrationTest):
self.c.revision,
self.e.revision,
[self.down_(self.e), self.down_(self.d)],
- set([self.c.revision]),
+ {self.c.revision},
)
self._assert_downgrade(
@@ -155,28 +155,28 @@ class RevisionPathTest(MigrationTest):
def test_relative_downgrade_path(self):
self._assert_downgrade(
- "-1", self.c.revision, [self.down_(self.c)], set([self.b.revision])
+ "-1", self.c.revision, [self.down_(self.c)], {self.b.revision}
)
self._assert_downgrade(
"-3",
self.e.revision,
[self.down_(self.e), self.down_(self.d), self.down_(self.c)],
- set([self.b.revision]),
+ {self.b.revision},
)
self._assert_downgrade(
"%s+2" % self.a.revision,
self.d.revision,
[self.down_(self.d)],
- set([self.c.revision]),
+ {self.c.revision},
)
self._assert_downgrade(
"%s-2" % self.c.revision,
self.d.revision,
[self.down_(self.d), self.down_(self.c), self.down_(self.b)],
- set([self.a.revision]),
+ {self.a.revision},
)
def test_invalid_relative_downgrade_path(self):
@@ -287,7 +287,7 @@ class BranchedPathTest(MigrationTest):
self.d1.revision,
self.b.revision,
[self.up_(self.c1), self.up_(self.d1)],
- set([self.d1.revision]),
+ {self.d1.revision},
)
def test_upgrade_multiple_branch(self):
@@ -303,7 +303,7 @@ class BranchedPathTest(MigrationTest):
self.up_(self.c1),
self.up_(self.d1),
],
- set([self.d1.revision, self.d2.revision]),
+ {self.d1.revision, self.d2.revision},
)
def test_downgrade_multiple_branch(self):
@@ -317,7 +317,7 @@ class BranchedPathTest(MigrationTest):
self.down_(self.c2),
self.down_(self.b),
],
- set([self.a.revision]),
+ {self.a.revision},
)
def test_relative_upgrade(self):
@@ -326,7 +326,7 @@ class BranchedPathTest(MigrationTest):
"c2branch@head-1",
self.b.revision,
[self.up_(self.c2)],
- set([self.c2.revision]),
+ {self.c2.revision},
)
def test_relative_downgrade_baseplus2(self):
@@ -340,7 +340,7 @@ class BranchedPathTest(MigrationTest):
self.down_(self.d2),
self.down_(self.c2),
],
- set([self.b.revision]),
+ {self.b.revision},
)
def test_relative_downgrade_branchplus2(self):
@@ -353,7 +353,7 @@ class BranchedPathTest(MigrationTest):
"c2branch@base+2",
[self.d2.revision, self.d1.revision],
[self.down_(self.d2), self.down_(self.c2)],
- set([self.d1.revision]),
+ {self.d1.revision},
)
def test_relative_downgrade_branchplus3(self):
@@ -362,13 +362,13 @@ class BranchedPathTest(MigrationTest):
self.c2.revision,
[self.d2.revision, self.d1.revision],
[self.down_(self.d2)],
- set([self.d1.revision, self.c2.revision]),
+ {self.d1.revision, self.c2.revision},
)
self._assert_downgrade(
"c2branch@base+3",
[self.d2.revision, self.d1.revision],
[self.down_(self.d2)],
- set([self.d1.revision, self.c2.revision]),
+ {self.d1.revision, self.c2.revision},
)
# Old downgrade -1 behaviour depends on order of branch upgrades.
@@ -381,7 +381,7 @@ class BranchedPathTest(MigrationTest):
"-1",
[self.d2.revision, self.d1.revision],
[self.down_(self.d2)],
- set([self.d1.revision, self.c2.revision]),
+ {self.d1.revision, self.c2.revision},
)
def test_downgrade_once_order_right_unbalanced(self):
@@ -390,7 +390,7 @@ class BranchedPathTest(MigrationTest):
"-1",
[self.c2.revision, self.d1.revision],
[self.down_(self.c2)],
- set([self.d1.revision]),
+ {self.d1.revision},
)
def test_downgrade_once_order_left(self):
@@ -399,7 +399,7 @@ class BranchedPathTest(MigrationTest):
"-1",
[self.d1.revision, self.d2.revision],
[self.down_(self.d1)],
- set([self.d2.revision, self.c1.revision]),
+ {self.d2.revision, self.c1.revision},
)
def test_downgrade_once_order_left_unbalanced(self):
@@ -408,7 +408,7 @@ class BranchedPathTest(MigrationTest):
"-1",
[self.c1.revision, self.d2.revision],
[self.down_(self.c1)],
- set([self.d2.revision]),
+ {self.d2.revision},
)
def test_downgrade_once_order_left_unbalanced_labelled(self):
@@ -416,73 +416,73 @@ class BranchedPathTest(MigrationTest):
"c1branch@-1",
[self.d1.revision, self.d2.revision],
[self.down_(self.d1)],
- set([self.c1.revision, self.d2.revision]),
+ {self.c1.revision, self.d2.revision},
)
# Captures https://github.com/sqlalchemy/alembic/issues/765
def test_downgrade_relative_order_right(self):
self._assert_downgrade(
- "{}-1".format(self.d2.revision),
+ f"{self.d2.revision}-1",
[self.d2.revision, self.c1.revision],
[self.down_(self.d2)],
- set([self.c1.revision, self.c2.revision]),
+ {self.c1.revision, self.c2.revision},
)
def test_downgrade_relative_order_left(self):
self._assert_downgrade(
- "{}-1".format(self.d2.revision),
+ f"{self.d2.revision}-1",
[self.c1.revision, self.d2.revision],
[self.down_(self.d2)],
- set([self.c1.revision, self.c2.revision]),
+ {self.c1.revision, self.c2.revision},
)
def test_downgrade_single_branch_c1branch(self):
"""Use branch label to specify the branch to downgrade."""
self._assert_downgrade(
- "c1branch@{}".format(self.b.revision),
+ f"c1branch@{self.b.revision}",
(self.c1.revision, self.d2.revision),
[
self.down_(self.c1),
],
- set([self.d2.revision]),
+ {self.d2.revision},
)
def test_downgrade_single_branch_c1branch_from_d1_head(self):
"""Use branch label to specify the branch (where the branch label is
not on the head revision)."""
self._assert_downgrade(
- "c2branch@{}".format(self.b.revision),
+ f"c2branch@{self.b.revision}",
(self.c1.revision, self.d2.revision),
[
self.down_(self.d2),
self.down_(self.c2),
],
- set([self.c1.revision]),
+ {self.c1.revision},
)
def test_downgrade_single_branch_c2(self):
"""Use a revision on the branch (not head) to specify the branch."""
self._assert_downgrade(
- "{}@{}".format(self.c2.revision, self.b.revision),
+ f"{self.c2.revision}@{self.b.revision}",
(self.d1.revision, self.d2.revision),
[
self.down_(self.d2),
self.down_(self.c2),
],
- set([self.d1.revision]),
+ {self.d1.revision},
)
def test_downgrade_single_branch_d1(self):
"""Use the head revision to specify the branch."""
self._assert_downgrade(
- "{}@{}".format(self.d1.revision, self.b.revision),
+ f"{self.d1.revision}@{self.b.revision}",
(self.d1.revision, self.d2.revision),
[
self.down_(self.d1),
self.down_(self.c1),
],
- set([self.d2.revision]),
+ {self.d2.revision},
)
def test_downgrade_relative_to_branch_head(self):
@@ -490,7 +490,7 @@ class BranchedPathTest(MigrationTest):
"c1branch@head-1",
(self.d1.revision, self.d2.revision),
[self.down_(self.d1)],
- set([self.c1.revision, self.d2.revision]),
+ {self.c1.revision, self.d2.revision},
)
def test_upgrade_other_branch_from_mergepoint(self):
@@ -500,7 +500,7 @@ class BranchedPathTest(MigrationTest):
"c2branch@+1",
(self.c1.revision),
[self.up_(self.c2)],
- set([self.c1.revision, self.c2.revision]),
+ {self.c1.revision, self.c2.revision},
)
def test_upgrade_one_branch_of_heads(self):
@@ -511,7 +511,7 @@ class BranchedPathTest(MigrationTest):
"c2branch@+1",
(self.c1.revision, self.c2.revision),
[self.up_(self.d2)],
- set([self.c1.revision, self.d2.revision]),
+ {self.c1.revision, self.d2.revision},
)
def test_ambiguous_upgrade(self):
@@ -525,13 +525,11 @@ class BranchedPathTest(MigrationTest):
def test_upgrade_from_base(self):
self._assert_upgrade(
- "base+1", [], [self.up_(self.a)], set([self.a.revision])
+ "base+1", [], [self.up_(self.a)], {self.a.revision}
)
def test_upgrade_from_base_implicit(self):
- self._assert_upgrade(
- "+1", [], [self.up_(self.a)], set([self.a.revision])
- )
+ self._assert_upgrade("+1", [], [self.up_(self.a)], {self.a.revision})
def test_downgrade_minus1_to_base(self):
self._assert_downgrade(
@@ -553,13 +551,13 @@ class BranchedPathTest(MigrationTest):
self.c2.revision,
[self.d1.revision, self.c2.revision],
[],
- set([self.d1.revision, self.c2.revision]),
+ {self.d1.revision, self.c2.revision},
)
self._assert_downgrade(
self.d1.revision,
[self.d1.revision, self.c2.revision],
[],
- set([self.d1.revision, self.c2.revision]),
+ {self.d1.revision, self.c2.revision},
)
@@ -614,7 +612,7 @@ class BranchFromMergepointTest(MigrationTest):
self.d1.revision,
(self.d2.revision, self.b1.revision),
[self.up_(self.c1), self.up_(self.d1)],
- set([self.d2.revision, self.d1.revision]),
+ {self.d2.revision, self.d1.revision},
)
def test_mergepoint_to_only_one_side_downgrade(self):
@@ -623,7 +621,7 @@ class BranchFromMergepointTest(MigrationTest):
self.b1.revision,
(self.d2.revision, self.d1.revision),
[self.down_(self.d1), self.down_(self.c1)],
- set([self.d2.revision, self.b1.revision]),
+ {self.d2.revision, self.b1.revision},
)
@@ -698,7 +696,7 @@ class BranchFrom3WayMergepointTest(MigrationTest):
self.d1.revision,
(self.d3.revision, self.d2.revision, self.b1.revision),
[self.up_(self.c1), self.up_(self.d1)],
- set([self.d3.revision, self.d2.revision, self.d1.revision]),
+ {self.d3.revision, self.d2.revision, self.d1.revision},
)
def test_mergepoint_to_only_one_side_downgrade(self):
@@ -706,7 +704,7 @@ class BranchFrom3WayMergepointTest(MigrationTest):
self.b1.revision,
(self.d3.revision, self.d2.revision, self.d1.revision),
[self.down_(self.d1), self.down_(self.c1)],
- set([self.d3.revision, self.d2.revision, self.b1.revision]),
+ {self.d3.revision, self.d2.revision, self.b1.revision},
)
def test_mergepoint_to_two_sides_upgrade(self):
@@ -716,7 +714,7 @@ class BranchFrom3WayMergepointTest(MigrationTest):
(self.d3.revision, self.b2.revision, self.b1.revision),
[self.up_(self.c2), self.up_(self.c1), self.up_(self.d1)],
# this will merge b2 and b1 into d1
- set([self.d3.revision, self.d1.revision]),
+ {self.d3.revision, self.d1.revision},
)
# but then! b2 will break out again if we keep going with it
@@ -724,7 +722,7 @@ class BranchFrom3WayMergepointTest(MigrationTest):
self.d2.revision,
(self.d3.revision, self.d1.revision),
[self.up_(self.d2)],
- set([self.d3.revision, self.d2.revision, self.d1.revision]),
+ {self.d3.revision, self.d2.revision, self.d1.revision},
)
@@ -916,14 +914,14 @@ class DependsOnBranchTestOne(MigrationTest):
heads = [self.c2.revision, self.d1.revision]
head = HeadMaintainer(mock.Mock(), heads)
head.update_to_step(self.down_(self.d1))
- eq_(head.heads, set([self.c2.revision]))
+ eq_(head.heads, {self.c2.revision})
def test_stamp_across_dependency(self):
heads = [self.e1.revision, self.c2.revision]
head = HeadMaintainer(mock.Mock(), heads)
for step in self.env._stamp_revs(self.b1.revision, heads):
head.update_to_step(step)
- eq_(head.heads, set([self.b1.revision]))
+ eq_(head.heads, {self.b1.revision})
class DependsOnBranchTestTwo(MigrationTest):
@@ -1010,15 +1008,13 @@ class DependsOnBranchTestTwo(MigrationTest):
self.b2.revision,
heads,
[self.down_(self.bmerge)],
- set(
- [
- self.amerge.revision,
- self.b1.revision,
- self.cmerge.revision,
- # b2 isn't here, but d1 is, which implies b2. OK!
- self.d1.revision,
- ]
- ),
+ {
+ self.amerge.revision,
+ self.b1.revision,
+ self.cmerge.revision,
+ # b2 isn't here, but d1 is, which implies b2. OK!
+ self.d1.revision,
+ },
)
# start with those heads..
@@ -1034,15 +1030,13 @@ class DependsOnBranchTestTwo(MigrationTest):
"d1@base",
heads,
[self.down_(self.d1)],
- set(
- [
- self.amerge.revision,
- self.b1.revision,
- # b2 has to be INSERTed, because it was implied by d1
- self.b2.revision,
- self.cmerge.revision,
- ]
- ),
+ {
+ self.amerge.revision,
+ self.b1.revision,
+ # b2 has to be INSERTed, because it was implied by d1
+ self.b2.revision,
+ self.cmerge.revision,
+ },
)
# start with those heads ...
@@ -1071,7 +1065,7 @@ class DependsOnBranchTestTwo(MigrationTest):
self.down_(self.c2),
self.down_(self.c3),
],
- set([]),
+ set(),
)
@@ -1122,7 +1116,7 @@ class DependsOnBranchTestThree(MigrationTest):
"b1",
["a3", "b2"],
[self.down_(self.b2)],
- set(["a3"]), # we have b1 also, which is implied by a3
+ {"a3"}, # we have b1 also, which is implied by a3
)
@@ -1145,7 +1139,7 @@ class DependsOnOwnDownrevTest(MigrationTest):
self.a2.revision,
None,
[self.up_(self.a1), self.up_(self.a2)],
- set(["a2"]),
+ {"a2"},
)
def test_traverse_down(self):
@@ -1153,7 +1147,7 @@ class DependsOnOwnDownrevTest(MigrationTest):
self.a1.revision,
self.a2.revision,
[self.down_(self.a2)],
- set(["a1"]),
+ {"a1"},
)
@@ -1190,7 +1184,7 @@ class DependsOnBranchTestFour(MigrationTest):
heads,
[self.down_(self.b4)],
# a3 isn't here, because b3 still implies a3
- set([self.b3.revision]),
+ {self.b3.revision},
)
@@ -1239,7 +1233,7 @@ class DependsOnBranchLabelTest(MigrationTest):
self.up_(self.b2),
self.up_(self.c2),
],
- set([self.c2.revision]),
+ {self.c2.revision},
)
@@ -1276,8 +1270,8 @@ class ForestTest(MigrationTest):
revs = self.env._stamp_revs("heads", ())
eq_(len(revs), 2)
eq_(
- set(r.to_revisions for r in revs),
- set([(self.b1.revision,), (self.b2.revision,)]),
+ {r.to_revisions for r in revs},
+ {(self.b1.revision,), (self.b2.revision,)},
)
def test_stamp_to_heads_no_moves_needed(self):
@@ -1448,19 +1442,19 @@ class BranchedPathTestCrossDependencies(MigrationTest):
"""c2branch depends on c1branch so can be taken down on its own.
Current behaviour also takes down the dependency unnecessarily."""
self._assert_downgrade(
- "c2branch@{}".format(self.b.revision),
+ f"c2branch@{self.b.revision}",
(self.d1.revision, self.d2.revision),
[
self.down_(self.d2),
self.down_(self.c2),
],
- set([self.d1.revision]),
+ {self.d1.revision},
)
def test_downgrade_branch_dependency(self):
"""c2branch depends on c1branch so taking down c1branch requires taking
down both"""
- destination = "c1branch@{}".format(self.b.revision)
+ destination = f"c1branch@{self.b.revision}"
source = self.d1.revision, self.d2.revision
revs = self.env._downgrade_revs(destination, source)
# Drops c1, d1 as requested, also drops d2 due to dependence on d1.
@@ -1483,4 +1477,4 @@ class BranchedPathTestCrossDependencies(MigrationTest):
head = HeadMaintainer(mock.Mock(), heads)
for rev in revs:
head.update_to_step(rev)
- eq_(head.heads, set([self.c2.revision]))
+ eq_(head.heads, {self.c2.revision})