From 51faef9fd45b4010791b149e6b42aba6c1775933 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Fri, 6 Mar 2020 14:31:08 +0100 Subject: [PATCH] [modules/kernel] Make widget dynamic (update if kernel changes) --- modules/core/kernel.py | 5 ++++- tests/modules/test_kernel.py | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/core/kernel.py b/modules/core/kernel.py index 99fc436..3e0dbf7 100644 --- a/modules/core/kernel.py +++ b/modules/core/kernel.py @@ -9,6 +9,9 @@ import core.widget class Module(core.module.Module): def __init__(self, config=None): - super().__init__(config, core.widget.Widget(platform.release())) + super().__init__(config, core.widget.Widget(self.full_text)) + + def full_text(self, widgets): + return platform.release() # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/tests/modules/test_kernel.py b/tests/modules/test_kernel.py index db9d37d..eeeb73d 100644 --- a/tests/modules/test_kernel.py +++ b/tests/modules/test_kernel.py @@ -5,12 +5,12 @@ import modules.core.kernel class kernel(unittest.TestCase): def setUp(self): self.someKernel = 'this-is-my-kernel' - with unittest.mock.patch('modules.core.kernel.platform') as platform: - platform.release.return_value = self.someKernel - self.module = modules.core.kernel.Module() + self.module = modules.core.kernel.Module() def test_full_text(self): - self.assertEqual(1, len(self.module.widgets())) - self.assertEqual(self.someKernel, self.module.widget().full_text()) + with unittest.mock.patch('modules.core.kernel.platform') as platform: + platform.release.return_value = self.someKernel + self.assertEqual(1, len(self.module.widgets())) + self.assertEqual(self.someKernel, self.module.widget().full_text()) # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4