Skip to content

Commit 9dc608f

Browse files
fix: restore file permissions in finally block for unreadable-file test
1 parent 9004768 commit 9dc608f

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

tests/test_main.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,15 @@ def upgrade():
165165
)
166166
import os
167167

168-
os.chmod(repo / "migrations" / "versions" / "026_unreadable.py", 0o000)
169-
with patch("sys.argv", ["squawk-alembic", path]):
170-
assert main() == 1
171-
os.chmod(repo / "migrations" / "versions" / "026_unreadable.py", 0o644)
172-
captured = capsys.readouterr()
173-
assert "cannot read migration file" in captured.err
168+
unreadable = repo / "migrations" / "versions" / "026_unreadable.py"
169+
os.chmod(unreadable, 0o000)
170+
try:
171+
with patch("sys.argv", ["squawk-alembic", path]):
172+
assert main() == 1
173+
captured = capsys.readouterr()
174+
assert "cannot read migration file" in captured.err
175+
finally:
176+
os.chmod(unreadable, 0o644)
174177

175178

176179
def test_missing_alembic_binary(repo, capsys):

0 commit comments

Comments
 (0)