diff --git a/tests/test_acme.py b/tests/test_acme.py index a069665..56b3457 100644 --- a/tests/test_acme.py +++ b/tests/test_acme.py @@ -61,14 +61,19 @@ class TestRunAcme: @patch("lib.acme._find_acme") @patch("lib.acme.subprocess.run") def test_log_flag_is_last(self, mock_run, mock_find): - # --log must trail the subcommand args: acme.sh would otherwise - # consume the first subcommand arg as its (optional) file argument. + # --log must trail the subcommand args: acme.sh would + # otherwise consume the first subcommand arg as its file argument. + # The explicit file path (not a bare trailing --log) is required + # because a valueless trailing --log makes acme.sh's arg loop + # double-shift under dash and fail with "shift: can't shift that + # many". mock_find.return_value = "/usr/local/bin/acme.sh" mock_run.return_value = MagicMock(returncode=0, stdout="", stderr="") acme._run_acme(["--issue", "-d", "example.com"]) cmd = mock_run.call_args[0][0] assert cmd.count("--log") == 1 - assert cmd[-1] == "--log" + assert cmd[-2] == "--log" + assert cmd[-1].endswith("acme.sh.log") assert cmd.index("--issue") < cmd.index("--log") assert "example.com" in cmd