Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ packages = [
]

[tool.mypy]
files = ["src"]
files = ['src', 'tests']
mypy_path = 'src'
explicit_package_bases = true
strict = true
Expand Down
2 changes: 1 addition & 1 deletion tests/demo/test__main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path


def test_quickstart_runs():
def test_quickstart_runs() -> None:
script = Path("demo/main.py")

result = subprocess.run(
Expand Down
4 changes: 2 additions & 2 deletions tests/driver/test_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@


@pytest.fixture(scope="function", autouse=True)
def setup(request: FixtureRequest) -> Generator[None]:
def setup(request: FixtureRequest) -> Generator[None, None, None]:
self: HasTestContextDesktopDriver = request.instance
self.desktop_driver = DesktopDriverWindowsImplementation()
node: Node = request.node
self.test_case_name = node.name
return
yield


@pytest.fixture(scope="function")
Expand Down
20 changes: 10 additions & 10 deletions tests/driver/test_find_element_by_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@


@pytest.fixture(scope="function", autouse=True)
def setup(request: FixtureRequest) -> Generator[None]:
def setup(request: FixtureRequest) -> Generator[None, None, None]:
self: HasTestContextDesktopDriver = request.instance
setup_common_paths(request)
self.desktop_driver = DesktopDriverWindowsImplementation()
node: Node = request.node
self.test_case_name = node.name
return
yield


class TestFindElementByImage:
desktop_driver: DesktopDriverInterface
test_case_name: str
test_suite_output_dir: str

def test_match_with_color_param(self):
def test_match_with_color_param(self) -> None:
gui_code_snippet = f"""
import tkinter as tk
root = tk.Tk()
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_match_with_color_param(self):

self.desktop_driver.close(OS_PROCESS_KILL_TIMEOUT=OS_PROCESS_KILL_TIMEOUT)

def test_image_detected_by_template_matching(self):
def test_image_detected_by_template_matching(self) -> None:
gui_code_snippet = f"""
import tkinter as tk
root = tk.Tk()
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_image_detected_by_template_matching(self):

self.desktop_driver.close(OS_PROCESS_KILL_TIMEOUT=OS_PROCESS_KILL_TIMEOUT)

def test_image_detected_with_altered_colors(self):
def test_image_detected_with_altered_colors(self) -> None:
gui_code_snippet = f"""
import tkinter as tk
root = tk.Tk()
Expand Down Expand Up @@ -171,7 +171,7 @@ def test_image_detected_with_altered_colors(self):

self.desktop_driver.close(OS_PROCESS_KILL_TIMEOUT=OS_PROCESS_KILL_TIMEOUT)

def test_element_detected_after_motion_stops(self):
def test_element_detected_after_motion_stops(self) -> None:
gui_code_snippet = f"""
import tkinter as tk, time, threading
root = tk.Tk()
Expand Down Expand Up @@ -213,7 +213,7 @@ def move():

self.desktop_driver.close(OS_PROCESS_KILL_TIMEOUT=OS_PROCESS_KILL_TIMEOUT)

def test_element_detected_despite_background_motion(self):
def test_element_detected_despite_background_motion(self) -> None:
gui_code_snippet = f"""
import tkinter as tk, threading, time
root = tk.Tk()
Expand Down Expand Up @@ -256,7 +256,7 @@ def wiggle():

self.desktop_driver.close(OS_PROCESS_KILL_TIMEOUT=OS_PROCESS_KILL_TIMEOUT)

def test_element_detected_but_not_stable(self):
def test_element_detected_but_not_stable(self) -> None:
gui_code_snippet = f"""
import tkinter as tk, threading, time
root = tk.Tk()
Expand Down Expand Up @@ -299,7 +299,7 @@ def wiggle():

self.desktop_driver.close(OS_PROCESS_KILL_TIMEOUT=OS_PROCESS_KILL_TIMEOUT)

def test_element_not_found(self):
def test_element_not_found(self) -> None:
gui_code_snippet = f"""
import tkinter as tk
root = tk.Tk()
Expand Down Expand Up @@ -332,7 +332,7 @@ def test_element_not_found(self):

self.desktop_driver.close(OS_PROCESS_KILL_TIMEOUT=OS_PROCESS_KILL_TIMEOUT)

def test_click_on_abrir_button_with_alpha_centered_image(self):
def test_click_on_abrir_button_with_alpha_centered_image(self) -> None:
gui_code_snippet = f"""
import tkinter as tk
root = tk.Tk()
Expand Down
8 changes: 4 additions & 4 deletions tests/driver/test_find_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@


@pytest.fixture(scope="function", autouse=True)
def setup(request: FixtureRequest) -> Generator[None]:
def setup(request: FixtureRequest) -> Generator[None, None, None]:
self: HasTestContextDesktopDriver = request.instance
self.desktop_driver = DesktopDriverWindowsImplementation()
node: Node = request.node
self.test_case_name = node.name
return
yield


@pytest.fixture(scope="function")
Expand All @@ -52,10 +52,10 @@ def dummy_app_path(request: FixtureRequest, tmp_path: Path) -> Path:
return path


def launch_gui_subprocess(script_path: Path) -> subprocess.Popen:
def launch_gui_subprocess(script_path: Path) -> subprocess.Popen[bytes]:
proc = subprocess.Popen(["python", str(script_path)])
for _ in range(30):
if any(script_path.stem == w.title for w in pywinctl.getAllWindows()):
if any(script_path.stem == w.title for w in pywinctl.getAllWindows()): # type: ignore[no-untyped-call]
break
time.sleep(0.1)
return proc
Expand Down
11 changes: 7 additions & 4 deletions tests/driver/test_switch_to.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re
from collections.abc import Generator
from typing import Any

import pytest
import pywinctl
Expand All @@ -24,13 +25,13 @@


@pytest.fixture(scope="function", autouse=True)
def setup(request: FixtureRequest) -> Generator[None]:
def setup(request: FixtureRequest) -> Generator[None, None, None]:
self: HasTestContextDesktopDriver = request.instance
setup_common_paths(request)
self.desktop_driver = DesktopDriverWindowsImplementation()
node: Node = request.node
self.test_case_name = node.name
return
yield


class TestSwitchTo:
Expand All @@ -39,12 +40,14 @@ class TestSwitchTo:
test_suite_output_dir: str

def test_switch_to_raises_on_invalid_type(self) -> None:
invalid_target: Any = "not a window object"
with pytest.raises(TypeError):
self.desktop_driver.switch_to(target_window="not a window object")
self.desktop_driver.switch_to(target_window=invalid_target)

def test_switch_to_raises_on_none(self) -> None:
invalid_target: Any = None
with pytest.raises(TypeError):
self.desktop_driver.switch_to(target_window=None)
self.desktop_driver.switch_to(target_window=invalid_target)

def test_switch_to_activates_window(self) -> None:
gui_code_snippet = f"""
Expand Down
8 changes: 4 additions & 4 deletions tests/driver/test_wait_for_window_to_disappear.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@


@pytest.fixture(scope="function", autouse=True)
def setup(request: FixtureRequest) -> Generator[None]:
def setup(request: FixtureRequest) -> Generator[None, None, None]:
self: HasTestContextDesktopDriver = request.instance
self.desktop_driver = DesktopDriverWindowsImplementation()
node: Node = request.node
self.test_case_name = node.name
return
yield


@pytest.fixture(scope="function")
Expand All @@ -52,10 +52,10 @@ def dummy_app_path(request: FixtureRequest, tmp_path: Path) -> Path:
return path


def launch_gui_subprocess(script_path: Path) -> subprocess.Popen:
def launch_gui_subprocess(script_path: Path) -> subprocess.Popen[bytes]:
proc = subprocess.Popen(["python", str(script_path)])
for _ in range(30):
if any(script_path.stem == w.title for w in pywinctl.getAllWindows()):
if any(script_path.stem == w.title for w in pywinctl.getAllWindows()): # type: ignore[no-untyped-call]
break
time.sleep(0.1)
return proc
Expand Down
4 changes: 2 additions & 2 deletions tests/element/test_action_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@


@pytest.fixture(scope="function", autouse=True)
def setup(request: FixtureRequest) -> Generator[None]:
def setup(request: FixtureRequest) -> Generator[None, None, None]:
self: HasTestContextDesktopDriver = request.instance
setup_common_paths(request)
self.desktop_driver = DesktopDriverWindowsImplementation()
node: Node = request.node
self.test_case_name = node.name
return
yield


class TestClickElement:
Expand Down
4 changes: 2 additions & 2 deletions tests/element/test_action_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@


@pytest.fixture(scope="function", autouse=True)
def setup(request: FixtureRequest) -> Generator[None]:
def setup(request: FixtureRequest) -> Generator[None, None, None]:
self: HasTestContextDesktopDriver = request.instance
setup_common_paths(request)
self.desktop_driver = DesktopDriverWindowsImplementation()
node: Node = request.node
self.test_case_name = node.name
return
yield


class TestTypeIntoEntry:
Expand Down