Skip to content

Commit

Permalink
Restore 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmess1221 committed Oct 9, 2024
1 parent 63bd813 commit f44f66e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@
assets_path = Path(__file__).parent / "assets"


@pytest.fixture(autouse=True)
def assets(monkeypatch: pytest.MonkeyPatch) -> None:
def test_dev(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.chdir(assets_path)


def test_dev() -> None:
with patch.object(uvicorn, "run") as mock_run:
result = runner.invoke(app, ["dev", "single_file_app.py"])
assert result.exit_code == 0, result.output
Expand All @@ -41,7 +37,8 @@ def test_dev() -> None:
assert "│ fastapi run" in result.output


def test_dev_args() -> None:
def test_dev_args(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.chdir(assets_path)
with patch.object(uvicorn, "run") as mock_run:
result = runner.invoke(
app,
Expand Down Expand Up @@ -80,7 +77,8 @@ def test_dev_args() -> None:
assert "│ fastapi run" in result.output


def test_run() -> None:
def test_run(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.chdir(assets_path)
with patch.object(uvicorn, "run") as mock_run:
result = runner.invoke(app, ["run", "single_file_app.py"])
assert result.exit_code == 0, result.output
Expand All @@ -103,7 +101,8 @@ def test_run() -> None:
assert "│ fastapi dev" in result.output


def test_run_args() -> None:
def test_run_args(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.chdir(assets_path)
with patch.object(uvicorn, "run") as mock_run:
result = runner.invoke(
app,
Expand Down Expand Up @@ -144,7 +143,8 @@ def test_run_args() -> None:
assert "│ fastapi dev" in result.output


def test_run_error() -> None:
def test_run_error(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.chdir(assets_path)
result = runner.invoke(app, ["run", "non_existing_file.py"])
assert result.exit_code == 1, result.output
assert "Path does not exist non_existing_file.py" in result.output
Expand Down

0 comments on commit f44f66e

Please sign in to comment.