From 2733238469c92fd486f60d86b4cf943a03007691 Mon Sep 17 00:00:00 2001 From: Tal Einat <532281+taleinat@users.noreply.github.com> Date: Thu, 12 May 2022 22:01:31 +0300 Subject: [PATCH 1/2] parse auto-restart's --kill-after parameter as a float This appears to be the originally intended behavior. --- src/watchdog/watchmedo.py | 1 + tests/test_0_watchmedo.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/watchdog/watchmedo.py b/src/watchdog/watchmedo.py index 0841c9a0..a3d1fd8a 100755 --- a/src/watchdog/watchmedo.py +++ b/src/watchdog/watchmedo.py @@ -579,6 +579,7 @@ def shell_command(args): argument('--kill-after', dest='kill_after', default=10.0, + type=float, help='When stopping, kill the subprocess after the specified timeout ' 'in seconds (default 10.0).')]) def auto_restart(args): diff --git a/tests/test_0_watchmedo.py b/tests/test_0_watchmedo.py index 312ba5a1..5da43146 100644 --- a/tests/test_0_watchmedo.py +++ b/tests/test_0_watchmedo.py @@ -74,6 +74,21 @@ def test_kill_auto_restart(tmpdir, capfd): # assert 'KeyboardInterrupt' in cap.err +def test_auto_restart_arg_parsing_basic(): + args = watchmedo.cli.parse_args(["auto-restart", "-d", ".", "cmd"]) + assert args.func is watchmedo.auto_restart + assert args.command == "cmd" + assert args.directories == ["."] + + +def test_auto_restart_arg_parsing_kill_after(): + args = watchmedo.cli.parse_args(["auto-restart", "-d", ".", "--kill-after", "12.5", "cmd"]) + assert args.func is watchmedo.auto_restart + assert args.command == "cmd" + assert args.directories == ["."] + assert args.kill_after == pytest.approx(12.5) + + @pytest.mark.parametrize("command", ["tricks-from", "tricks"]) def test_tricks_from_file(command, tmp_path): tricks_file = tmp_path / "tricks.yaml" From 725608b9f42bb93f06f62496d056edd7782f4e63 Mon Sep 17 00:00:00 2001 From: Tal Einat <532281+taleinat@users.noreply.github.com> Date: Thu, 12 May 2022 22:19:11 +0300 Subject: [PATCH 2/2] update changlog --- changelog.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog.rst b/changelog.rst index ffc8fb02..900a55df 100644 --- a/changelog.rst +++ b/changelog.rst @@ -8,8 +8,8 @@ Changelog 2022-xx-xx • `full history `__ -- -- Thanks to our beloved contributors: @ +- [watchmedo] Fix broken parsing of ``--kill-after`` argument for the ``auto-restart`` command. (`#870 `_) +- Thanks to our beloved contributors: @taleinat 2.1.7 ~~~~~