diff --git a/pyproject.toml b/pyproject.toml index 3d7b0289..84b93d88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" [project] name = "ops-scenario" -version = "5.7" +version = "5.7.1" authors = [ { name = "Pietro Pasotti", email = "pietro.pasotti@canonical.com" } diff --git a/scenario/context.py b/scenario/context.py index ebdecb93..99c8a602 100644 --- a/scenario/context.py +++ b/scenario/context.py @@ -296,7 +296,18 @@ def _get_storage_root(self, name: str, index: int) -> Path: return storage_root def clear(self): - """Cleanup side effects histories.""" + """Deprecated. + + Use cleanup instead. + """ + logger.warning( + "Context.clear() is deprecated and will be nuked in v6. " + "Use Context.cleanup() instead.", + ) + self.cleanup() + + def cleanup(self): + """Cleanup side effects histories and reset the simulated filesystem state.""" self.juju_log = [] self.app_status_history = [] self.unit_status_history = [] @@ -308,6 +319,9 @@ def clear(self): self._action_failure = None self._output_state = None + self._tmp.cleanup() + self._tmp = tempfile.TemporaryDirectory() + def _record_status(self, state: "State", is_app: bool): """Record the previous status before a status change.""" if is_app: