Skip to content

Commit 1db5567

Browse files
authored
Apply suggestions from code review
Co-authored-by: yyyyyyy <contact@yyyyyyyan.tech>
1 parent f0d4361 commit 1db5567

2 files changed

Lines changed: 4 additions & 26 deletions

File tree

scripts/check_alembic_revision_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def main(argv: list[str] | None = None) -> int:
125125
try:
126126
trees = inspect_revision_trees(args.ini)
127127
except (ValueError, OSError) as exc:
128-
print(f"{args.ini}: {exc}", file=sys.stderr)
128+
print(exc, file=sys.stderr)
129129
return 1
130130
failed = [tree for tree in trees if tree.is_forked]
131131
if not failed:

tests/scripts/test_check_alembic_revision_tree.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def _write_ini(
8282
lines = [
8383
"[alembic]",
8484
f"databases = {databases}",
85-
"version_path_separator = :",
8685
"",
8786
"[DEFAULT]",
8887
"path_separator = :",
@@ -180,19 +179,7 @@ def test_check_passes_on_reconverged_siblings(tmp_path, capsys):
180179
_write_revision(versions_dir, "base", None)
181180
_write_revision(versions_dir, "c1", "base")
182181
_write_revision(versions_dir, "c2", "base")
183-
merge_template = """\
184-
revision = 'm'
185-
down_revision = ('c1', 'c2')
186-
branch_labels = None
187-
depends_on = None
188-
189-
def upgrade():
190-
pass
191-
192-
def downgrade():
193-
pass
194-
"""
195-
(versions_dir / "m.py").write_text(merge_template, encoding="utf-8")
182+
_write_revision(versions_dir, "m", ("c1", "c2"))
196183
ini_path = _write_ini(
197184
tmp_path,
198185
databases="widget",
@@ -211,17 +198,10 @@ def downgrade():
211198

212199
def test_discovers_tracks_from_databases_key(tmp_path):
213200
"""Discover track names from ``[alembic] databases``, not hard-coded lists."""
214-
script_a = _dummy_script_location(tmp_path, "migrations_a")
215-
script_b = _dummy_script_location(tmp_path, "migrations_b")
216-
(script_a / "versions").mkdir()
217-
(script_b / "versions").mkdir()
218201
ini_path = _write_ini(
219202
tmp_path,
220203
databases="widget, gadget",
221-
sections={
222-
"widget": {"script_location": str(script_a)},
223-
"gadget": {"script_location": str(script_b)},
224-
},
204+
sections={"widget": {}, "gadget": {}},
225205
)
226206

227207
assert check_alembic_revision_tree.list_track_names(ini_path) == (
@@ -316,16 +296,14 @@ def test_reintroducing_sep_1824_fork_fails(tmp_path, capsys):
316296
tree = trees[0]
317297
assert tree.name == "tasks"
318298
assert tree.is_forked is True
319-
assert "a19da5cf0bca" in tree.heads
299+
assert len(tree.heads) == len(tree.roots) + 1
320300
assert "e2f3a4b5c6d7" in tree.heads
321301

322302
error = check_alembic_revision_tree.format_fork_error(tree)
323303
assert "tasks" in error
324-
assert "a19da5cf0bca" in error
325304
assert "e2f3a4b5c6d7" in error
326305

327306
assert check_alembic_revision_tree.main(["--ini", str(ini_path)]) == 1
328307
err = capsys.readouterr().err
329308
assert "tasks" in err
330-
assert "a19da5cf0bca" in err
331309
assert "e2f3a4b5c6d7" in err

0 commit comments

Comments
 (0)