Skip to content

Commit

Permalink
fix(test): fix application tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lengau committed Feb 21, 2025
1 parent 98832c8 commit 40d2762
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion craft_application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def _run_inner(self) -> int:
build_for = build_for.split(",", maxsplit=1)[0]
if command.needs_project(dispatcher.parsed_args()):
project_service = self.services.get("project")
# This is only needed for testing.
# This branch always runs, except during testing.
if not project_service.is_rendered:
project_service.render_once()

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,13 @@ def test_gets_project(monkeypatch, fake_project_file, app_metadata, fake_service


def test_fails_without_project(
monkeypatch, capsys, tmp_path, app_metadata, fake_services, app
monkeypatch, capsys, tmp_path, app_metadata, fake_services, app, debug_mode
):
monkeypatch.setattr(sys, "argv", ["testcraft", "prime"])

app.project_dir = tmp_path
# Set up a real project service - the fake one for testing gets a fake project!
del app.services._services["project"]
app.services.register("project", services.ProjectService)

fake_services.project = None
monkeypatch.setattr(sys, "argv", ["testcraft", "prime"])

assert app.run() == 66

Expand Down

0 comments on commit 40d2762

Please sign in to comment.