Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
elParaguayo committed Nov 20, 2024
1 parent e61ef8d commit 39fd9ee
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import asyncio

import pytest

import libqtile.bar
Expand All @@ -36,6 +38,7 @@
from libqtile.ipc import Client, IPCError
from libqtile.lazy import lazy
from test.conftest import dualmonitor
from test.helpers import Retry


class CallConfig(Config):
Expand Down Expand Up @@ -458,6 +461,28 @@ def test_func(qtile, value, multiplier=1):
assert val == "500"


def test_lazy_function_coroutine(manager_nospawn):
"""Test that lazy.function accepts coroutines."""

@Retry(ignore_exceptions=(AssertionError,))
def assert_func_text(manager, value):
_, text = manager.c.eval("self.test_func_output")
assert text == value

@lazy.function
async def test_async_func(qtile, value):
await asyncio.sleep(0.1)
qtile.test_func_output = value

config = ServerConfig
config.keys = [libqtile.config.Key(["control"], "k", test_async_func("qtile"))]

manager_nospawn.start(config)

manager_nospawn.c.simulate_keypress(["control"], "k")
assert_func_text(manager_nospawn, "qtile")


def test_decorators_direct_call():
widget = DecoratedTextBox()
undecorated = libqtile.widget.TextBox()
Expand Down

0 comments on commit 39fd9ee

Please sign in to comment.