From a1b32a5188b896b946df8ff757384390bc9d2a76 Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 24 Jan 2025 17:21:42 +0900 Subject: [PATCH] chore: make event_name mandatory in Framework --- ops/_private/harness.py | 1 + ops/framework.py | 2 +- test/test_framework.py | 2 ++ test/test_helpers.py | 1 + test/test_storage.py | 1 + 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ops/_private/harness.py b/ops/_private/harness.py index 009b7ff94..cfd91de92 100644 --- a/ops/_private/harness.py +++ b/ops/_private/harness.py @@ -312,6 +312,7 @@ def __init__( self._charm_dir, self._meta, self._model, + '', juju_debug_at=self._juju_context.debug_at, # Harness tests will often have defer() usage without 'purging' the # deferred handler with reemit(), but still expect the next emit() diff --git a/ops/framework.py b/ops/framework.py index 1d497704c..d79c0b64e 100644 --- a/ops/framework.py +++ b/ops/framework.py @@ -606,7 +606,7 @@ def __init__( charm_dir: Union[str, pathlib.Path], meta: 'charm.CharmMeta', model: 'Model', - event_name: Optional[str] = None, + event_name: str, juju_debug_at: Optional[Set[str]] = None, skip_duplicate_events: bool = True, ): diff --git a/test/test_framework.py b/test/test_framework.py index 184094c80..37bdef377 100644 --- a/test/test_framework.py +++ b/test/test_framework.py @@ -73,6 +73,7 @@ def create_framework( charm_dir, meta=model._cache._meta if model else ops.CharmMeta(), model=model, # type: ignore + event_name='', juju_debug_at=_JujuContext.from_dict(os.environ).debug_at, ) request.addfinalizer(framework.close) @@ -94,6 +95,7 @@ def test_deprecated_init(self, caplog: pytest.LogCaptureFixture): None, # type: ignore None, # type: ignore None, # type: ignore + '', juju_debug_at=set(), ) assert 'WARNING:ops.framework:deprecated: Framework now takes a Storage not a path' in [ diff --git a/test/test_helpers.py b/test/test_helpers.py index a97fa8e06..c07433332 100644 --- a/test/test_helpers.py +++ b/test/test_helpers.py @@ -112,6 +112,7 @@ class TestCharmEvents(ops.CharmEvents): tmpdir, meta, model, + 'foo_event', juju_debug_at=_JujuContext.from_dict(os.environ).debug_at, ) diff --git a/test/test_storage.py b/test/test_storage.py index 6c5a842a9..fa769cfcb 100644 --- a/test/test_storage.py +++ b/test/test_storage.py @@ -54,6 +54,7 @@ def create_framework( None, # type: ignore None, # type: ignore None, # type: ignore + '', juju_debug_at=set(), )