Skip to content

Commit

Permalink
window tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spyoungtech committed Dec 13, 2018
1 parent 827a0ca commit 290a4ca
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions tests/unittests/test_win_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,34 @@
project_root = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../..'))
sys.path.insert(0, project_root)
from ahk import AHK
from ahk.window import WindowNotFoundError
import pytest
import subprocess
ahk = AHK()

def test_get_calculator():
with subprocess.Popen('calc') as p:
time.sleep(2) # give calculator some time to start up; may replace this once WinWait is implemented
win = ahk.win_get(title='Calculator')
p = None
try:
p = subprocess.Popen('notepad')
time.sleep(1) # give notepad time to start up
win = ahk.win_get(title='Untitled - Notepad')
assert win
assert win.position
finally:
if p is not None:
p.terminate()

def test_win_close():
p = None
try:
p = subprocess.Popen('notepad')
time.sleep(1) # give notepad time to start up
win = ahk.win_get(title='Untitled - Notepad')
assert win
assert win.position
win.close()
with pytest.raises(WindowNotFoundError):
ahk.win_get(title='Untitled - Notepad').position
finally:
if p is not None:
p.terminate()

0 comments on commit 290a4ca

Please sign in to comment.