-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
1 parent
1da2609
commit 468cfd5
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import asyncio | ||
import os | ||
import pathlib | ||
import subprocess | ||
import sys | ||
import time | ||
from unittest import TestCase | ||
from unittest import mock | ||
|
||
from ahk import AHK | ||
from ahk import Window | ||
|
||
|
||
sleep = time.sleep | ||
|
||
|
||
class TestScripts(TestCase): | ||
win: Window | ||
|
||
def setUp(self) -> None: | ||
self.ahk = AHK() | ||
|
||
def tearDown(self) -> None: | ||
try: | ||
self.ahk._transport._proc.kill() | ||
except: | ||
pass | ||
time.sleep(0.2) | ||
|
||
def test_script_missing_makes_tempfile(self): | ||
with mock.patch('os.path.exists', new=mock.Mock(return_value=False)): | ||
pos = self.ahk.get_mouse_position() | ||
path = pathlib.Path(self.ahk._transport._proc.runargs[-1]) | ||
filename = path.name | ||
assert filename.startswith('python-ahk-') | ||
assert filename.endswith('.ahk') | ||
assert isinstance(pos, tuple) and isinstance(pos[0], int) |