@@ -0,0 +1,2155 @@
+# Copyright (c) 2021 elParaguayo%0A#%0A# Permission is hereby granted, free of charge, to any person obtaining a copy%0A# of this software and associated documentation files (the %22Software%22), to deal%0A# in the Software without restriction, including without limitation the rights%0A# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A# copies of the Software, and to permit persons to whom the Software is%0A# furnished to do so, subject to the following conditions:%0A#%0A# The above copyright notice and this permission notice shall be included in%0A# all copies or substantial portions of the Software.%0A#%0A# THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE%0A# SOFTWARE.%0A%0A# Widget specific tests%0Aimport sys%0Afrom importlib import reload%0Afrom types import ModuleType%0A%0Aimport pytest%0A%0Aimport libqtile.config%0Aimport libqtile.widget%0Afrom libqtile.bar import Bar%0A%0A%0Aclass MockPsutil(ModuleType):%0A    @classmethod%0A    def cpu_percent(cls):%0A        return 2.6%0A%0A    @classmethod%0A    def cpu_freq(cls):%0A        class Freq:%0A            def __init__(self):%0A                self.current = 500.067%0A                self.min = 400.0%0A                self.max = 2800.0%0A%0A        return Freq()%0A%0A%0A@pytest.fixture%0Adef cpu_manager(monkeypatch, manager_nospawn, minimal_conf_noscreen):%0A    monkeypatch.setitem(sys.modules, %22psutil%22, MockPsutil(%22psutil%22))%0A    from libqtile.widget import cpu%0A    reload(cpu)%0A%0A    config = minimal_conf_noscreen%0A    config.screens = %5B%0A        libqtile.config.Screen(%0A            top=Bar(%0A                %5Bcpu.CPU()%5D,%0A                10%0A            )%0A        )%0A    %5D%0A%0A    manager_nospawn.start(config)%0A    yield manager_nospawn%0A%0A%0Adef test_cpu(cpu_manager):%0A    assert cpu_manager.c.widget%5B%22cpu%22%5D.info()%5B%22text%22%5D == %22CPU 0.5GHz 2.6%25%22%0A

Add test for CPU widget