Skip to content

Commit

Permalink
mock things correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaqq committed Aug 27, 2024
1 parent 8e182f6 commit aca6448
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def __init__(
self.check_name = check_name


@patch('ops.main.setup_root_logging', new=lambda *a, **kw: None) # type: ignore
@patch('ops.main._emit_charm_event', new=lambda *a, **kw: None) # type: ignore
@patch('ops._main.setup_root_logging', new=lambda *a, **kw: None) # type: ignore
@patch('ops._main._emit_charm_event', new=lambda *a, **kw: None) # type: ignore
@patch('ops.charm._evaluate_status', new=lambda *a, **kw: None) # type: ignore
class TestCharmInit:
@patch('sys.stderr', new_callable=io.StringIO)
Expand Down Expand Up @@ -203,7 +203,7 @@ def test_controller_storage_deprecated(self):


@patch('sys.argv', new=('hooks/config-changed',))
@patch('ops.main._Manager._setup_root_logging', new=lambda *a, **kw: None) # type: ignore
@patch('ops._main._Manager._setup_root_logging', new=lambda *a, **kw: None) # type: ignore
@patch('ops.charm._evaluate_status', new=lambda *a, **kw: None) # type: ignore
class TestDispatch:
def _check(self, *, with_dispatch: bool = False, dispatch_path: str = ''):
Expand Down Expand Up @@ -235,7 +235,7 @@ def __init__(self, framework: ops.Framework):
dispatch.chmod(0o755)

with patch.dict(os.environ, fake_environ):
with patch('ops.main._emit_charm_event') as mock_charm_event:
with patch('ops._main._emit_charm_event') as mock_charm_event:
ops.main(MyCharm)

assert mock_charm_event.call_count == 1
Expand Down

0 comments on commit aca6448

Please sign in to comment.