Skip to content

Commit

Permalink
fix: all lifecycle commands need a project
Browse files Browse the repository at this point in the history
  • Loading branch information
tigarmo authored and sergiusens committed Oct 6, 2023
1 parent c0dd21a commit bfbc5f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion craft_application/commands/lifecycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def run(self, parsed_args: argparse.Namespace) -> None:


class _LifecyclePartsCommand(_LifecycleCommand):
# All lifecycle-related commands need a project to work
always_load_project = True

@override
def fill_parser(self, parser: argparse.ArgumentParser) -> None:
super().fill_parser(parser) # type: ignore[arg-type]
Expand Down Expand Up @@ -321,7 +324,6 @@ class CleanCommand(_LifecyclePartsCommand):
remove the packing environment.
"""
)
always_load_project = True

@override
def run(self, parsed_args: argparse.Namespace) -> None:
Expand Down
8 changes: 5 additions & 3 deletions tests/integration/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
import craft_cli
import pytest
import pytest_check
from overrides import override
from typing_extensions import override


@pytest.fixture()
def create_app(app_metadata, fake_project, fake_package_service_class):
def create_app(app_metadata, fake_package_service_class):
def _inner():
# Create a factory without a project, to simulate a real application use
# and force loading from disk.
services = craft_application.ServiceFactory(
app_metadata, project=fake_project, PackageClass=fake_package_service_class
app_metadata, PackageClass=fake_package_service_class
)
return craft_application.Application(app_metadata, services)

Expand Down

0 comments on commit bfbc5f2

Please sign in to comment.