Bug fix and more #20
@@ -491,6 +491,10 @@ def main():
|
|||||||
target = Path(file_arg).expanduser().resolve()
|
target = Path(file_arg).expanduser().resolve()
|
||||||
backup_dir = Path(args.backup_dir).expanduser().resolve()
|
backup_dir = Path(args.backup_dir).expanduser().resolve()
|
||||||
|
|
||||||
|
if target.is_dir():
|
||||||
|
print(f"'{target}' is a directory!")
|
||||||
|
return 1
|
||||||
|
|
||||||
# Permission checks
|
# Permission checks
|
||||||
parent = target.parent
|
parent = target.parent
|
||||||
if target.exists() and not os.access(target, os.W_OK):
|
if target.exists() and not os.access(target, os.W_OK):
|
||||||
|
|||||||
@@ -174,6 +174,17 @@ def test_main_missing_argument(capsys):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_main_rejects_directory(tmp_path, capsys):
|
||||||
|
target = tmp_path / "dir"
|
||||||
|
target.mkdir()
|
||||||
|
|
||||||
|
with patch("sys.argv", ["mirro", str(target)]):
|
||||||
|
result = mirro.main()
|
||||||
|
|
||||||
|
assert result == 1
|
||||||
|
assert f"'{target}' is a directory!" in capsys.readouterr().out
|
||||||
|
|
||||||
|
|
||||||
# ============================================================
|
# ============================================================
|
||||||
# main: unchanged file
|
# main: unchanged file
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user