Skip to content

Commit

Permalink
add msgbox tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spyoungtech committed Jul 30, 2023
1 parent 8e425d1 commit d164ef7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/_async/test_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import asyncio
import time
import unittest

import pytest

from ahk import AsyncAHK

async_sleep = asyncio.sleep # unasync: remove

sleep = time.sleep


class TestGui(unittest.IsolatedAsyncioTestCase):
async def asyncSetUp(self) -> None:
self.ahk = AsyncAHK()

async def asyncTearDown(self) -> None:
self.ahk._transport._proc.kill()
time.sleep(0.2)

async def test_msg_box(self):
box = await self.ahk.msg_box(text='hello', title='test', timeout=3, blocking=False)
await async_sleep(1)
win = await self.ahk.win_get(title='test')
assert win is not None
with pytest.raises(TimeoutError):
r = await box.result()
27 changes: 27 additions & 0 deletions tests/_sync/test_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import asyncio
import time
import unittest

import pytest

from ahk import AHK


sleep = time.sleep


class TestGui(unittest.TestCase):
def setUp(self) -> None:
self.ahk = AHK()

def tearDown(self) -> None:
self.ahk._transport._proc.kill()
time.sleep(0.2)

def test_msg_box(self):
box = self.ahk.msg_box(text='hello', title='test', timeout=3, blocking=False)
sleep(1)
win = self.ahk.win_get(title='test')
assert win is not None
with pytest.raises(TimeoutError):
r = box.result()

0 comments on commit d164ef7

Please sign in to comment.