Skip to content

Commit f44f66e

Browse files
committed
Restore 100% coverage
1 parent 63bd813 commit f44f66e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/test_cli.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@
1313
assets_path = Path(__file__).parent / "assets"
1414

1515

16-
@pytest.fixture(autouse=True)
17-
def assets(monkeypatch: pytest.MonkeyPatch) -> None:
16+
def test_dev(monkeypatch: pytest.MonkeyPatch) -> None:
1817
monkeypatch.chdir(assets_path)
19-
20-
21-
def test_dev() -> None:
2218
with patch.object(uvicorn, "run") as mock_run:
2319
result = runner.invoke(app, ["dev", "single_file_app.py"])
2420
assert result.exit_code == 0, result.output
@@ -41,7 +37,8 @@ def test_dev() -> None:
4137
assert "│ fastapi run" in result.output
4238

4339

44-
def test_dev_args() -> None:
40+
def test_dev_args(monkeypatch: pytest.MonkeyPatch) -> None:
41+
monkeypatch.chdir(assets_path)
4542
with patch.object(uvicorn, "run") as mock_run:
4643
result = runner.invoke(
4744
app,
@@ -80,7 +77,8 @@ def test_dev_args() -> None:
8077
assert "│ fastapi run" in result.output
8178

8279

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

105103

106-
def test_run_args() -> None:
104+
def test_run_args(monkeypatch: pytest.MonkeyPatch) -> None:
105+
monkeypatch.chdir(assets_path)
107106
with patch.object(uvicorn, "run") as mock_run:
108107
result = runner.invoke(
109108
app,
@@ -144,7 +143,8 @@ def test_run_args() -> None:
144143
assert "│ fastapi dev" in result.output
145144

146145

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

0 commit comments

Comments
 (0)