From 471f99de8d684397ef318512c2ebf704fec74b82 Mon Sep 17 00:00:00 2001 From: Irfanuddin Date: Fri, 28 Oct 2022 23:46:52 +0530 Subject: [PATCH 1/4] wip: add logic ts to improve coverage --- tests/test_cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index 0d34d1d36..eb950ff88 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -95,6 +95,7 @@ def test_cli_call_multiprocess_run() -> None: def test_cli_uds(tmp_path: Path) -> None: # pragma: py-win32 runner = CliRunner() uds_file = tmp_path / "uvicorn.sock" + uds_file.touch(exist_ok=True) with mock.patch.object(Config, "bind_socket") as mock_bind_socket: with mock.patch.object(Multiprocess, "run") as mock_run: From 673ef0a89bee95d65f366578cb0b0de080b3593e Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 29 Oct 2022 09:25:56 +0200 Subject: [PATCH 2/4] Create uds_file fixture --- setup.cfg | 2 +- tests/test_cli.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 33c3e95a3..40866bb9b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -82,7 +82,7 @@ plugins = [coverage:report] precision = 2 -fail_under = 97.69 +fail_under = 97.81 show_missing = true skip_covered = true exclude_lines = diff --git a/tests/test_cli.py b/tests/test_cli.py index eb950ff88..b97529ab8 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -91,11 +91,18 @@ def test_cli_call_multiprocess_run() -> None: mock_run.assert_called_once() +@pytest.fixture(params=(True, False)) +def uds_file(tmp_path: Path, request: pytest.FixtureRequest) -> Path: + file = tmp_path / "uvicorn.sock" + should_create_file = request.param + if should_create_file: + file.touch(exist_ok=True) + return file + + @pytest.mark.skipif(sys.platform == "win32", reason="require unix-like system") -def test_cli_uds(tmp_path: Path) -> None: # pragma: py-win32 +def test_cli_uds(uds_file: Path) -> None: # pragma: py-win32 runner = CliRunner() - uds_file = tmp_path / "uvicorn.sock" - uds_file.touch(exist_ok=True) with mock.patch.object(Config, "bind_socket") as mock_bind_socket: with mock.patch.object(Multiprocess, "run") as mock_run: From a3d90a3ee9a1efc8e880077086d82635a7e97efb Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 29 Oct 2022 09:29:11 +0200 Subject: [PATCH 3/4] Adjust fail_under number --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 40866bb9b..8ec8fbbf6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -82,7 +82,7 @@ plugins = [coverage:report] precision = 2 -fail_under = 97.81 +fail_under = 97.79 show_missing = true skip_covered = true exclude_lines = From c9e4d214d3f6e2173024a7a2cf0b3dfceb0dc3d9 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 29 Oct 2022 09:38:19 +0200 Subject: [PATCH 4/4] Add pragma on Windows --- tests/test_cli.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index b97529ab8..ae22fef6a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -92,7 +92,9 @@ def test_cli_call_multiprocess_run() -> None: @pytest.fixture(params=(True, False)) -def uds_file(tmp_path: Path, request: pytest.FixtureRequest) -> Path: +def uds_file( + tmp_path: Path, request: pytest.FixtureRequest +) -> Path: # pragma: py-win32 file = tmp_path / "uvicorn.sock" should_create_file = request.param if should_create_file: