Skip to content

Commit

Permalink
added container fs temporary dir cleanup in Context.clear() --> Conte…
Browse files Browse the repository at this point in the history
…xt.cleanup()
  • Loading branch information
PietroPasotti committed Nov 17, 2023
1 parent 31ab9dd commit ae4a8ee
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scenario/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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:
Expand Down

0 comments on commit ae4a8ee

Please sign in to comment.