From d19eb7229642387b32419eb195923331d8640361 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Wed, 4 Mar 2020 21:06:09 +0100 Subject: [PATCH] [tests/module] Test generation of error widget When a module/widget throws, an error widget should be produced. --- tests/core/test_module.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/core/test_module.py b/tests/core/test_module.py index 2fb4123..6e1542e 100644 --- a/tests/core/test_module.py +++ b/tests/core/test_module.py @@ -7,7 +7,10 @@ import core.widget import core.config class TestModule(core.module.Module): - pass + def update(self): + if self.fail: + raise Exception(self.error) + pass class module(unittest.TestCase): def setUp(self): @@ -68,4 +71,13 @@ class module(unittest.TestCase): module = TestModule(config=cfg) self.assertEqual(None, module.parameter('foo')) + def test_error_widget(self): + cfg = core.config.Config([]) + module = TestModule(config=cfg) + module.fail = True + module.error = '!!' + module.update_wrapper() + self.assertEqual(1, len(module.widgets())) + self.assertEqual('error: !!', module.widget().full_text()) + # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4