Skip to content

Commit

Permalink
Add test scenario for --uds flag when file exists (#1741)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
  • Loading branch information
iudeen and Kludex committed Oct 29, 2022
1 parent 6c67565 commit 641e8c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -82,7 +82,7 @@ plugins =

[coverage:report]
precision = 2
fail_under = 97.69
fail_under = 97.79
show_missing = true
skip_covered = true
exclude_lines =
Expand Down
14 changes: 12 additions & 2 deletions tests/test_cli.py
Expand Up @@ -91,10 +91,20 @@ 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: # pragma: py-win32
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"

with mock.patch.object(Config, "bind_socket") as mock_bind_socket:
with mock.patch.object(Multiprocess, "run") as mock_run:
Expand Down

0 comments on commit 641e8c5

Please sign in to comment.