Skip to content

Commit

Permalink
Fix bug that prevented module errors being displayed in bar (enkore#586)
Browse files Browse the repository at this point in the history
* Fix bug that prevented errors being shown in bar.

* Add tests to ensure errors are visible in the bar.
  • Loading branch information
facetoe committed Jun 16, 2017
1 parent 4ec39ca commit 1db757a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion i3pystatus/core/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class Module(SettingsBase):
hints = {"markup": "none"}

def __init__(self, *args, **kwargs):
super(Module, self).__init__(*args, **kwargs)
self._output = None
super(Module, self).__init__(*args, **kwargs)
self.__multi_click = MultiClickHandler(self.__button_callback_handler,
self.multi_click_timeout)

Expand Down
20 changes: 19 additions & 1 deletion tests/test_core_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import MagicMock

import pytest
from i3pystatus import IntervalModule
from i3pystatus import IntervalModule, Status
from i3pystatus.core.exceptions import ConfigMissingError
from i3pystatus.core.modules import is_method_of, Module

Expand Down Expand Up @@ -162,6 +162,24 @@ class TestRequired(Module):
TestRequired(some_setting='foo')


def test_invalid_module_kwarg_shows_error():
""" Ensure that when an invalid module kwarg is passed an error is shown in the bar. """
status = Status(standalone=False)
status.register("text", foo='bar')
assert len(status.modules) > 0
assert status.modules[0].output is not None
assert "ConfigKeyError" in status.modules[0].output['full_text']


def test_missing_required_shows_error():
""" Ensure that when an a required module parameter is missing an error is shown in the bar. """
status = Status(standalone=False)
status.register("text")
assert len(status.modules) > 0
assert status.modules[0].output is not None
assert "ConfigMissingError" in status.modules[0].output['full_text']


def test_required_defined_raises():
""" Ensure defined but unmodified required settings raise a ConfigMissingError """

Expand Down

0 comments on commit 1db757a

Please sign in to comment.