From 76dbaa1a4d69c82fcb725028d23d8ffa45544e44 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 22 Feb 2026 00:57:07 +0000 Subject: [PATCH] Add @beartype to test helper functions Add runtime type checking to non-fixture test helpers that were missing it: processing_time_seconds, make_image_file, Endpoint.send, assert_vwq_failure, _wait_for_target_processed, _delete_all_targets. Co-authored-by: Cursor --- tests/mock_vws/fixtures/prepared_requests.py | 2 ++ tests/mock_vws/fixtures/vuforia_backends.py | 1 + tests/mock_vws/utils/__init__.py | 3 +++ tests/mock_vws/utils/assertions.py | 1 + tests/mock_vws/utils/usage_test_helpers.py | 2 ++ 5 files changed, 9 insertions(+) diff --git a/tests/mock_vws/fixtures/prepared_requests.py b/tests/mock_vws/fixtures/prepared_requests.py index 52dd0880f..87effa6b1 100644 --- a/tests/mock_vws/fixtures/prepared_requests.py +++ b/tests/mock_vws/fixtures/prepared_requests.py @@ -8,6 +8,7 @@ from uuid import uuid4 import pytest +from beartype import beartype from urllib3.filepost import encode_multipart_formdata from vws import VWS from vws_auth_tools import authorization_header, rfc_1123_date @@ -22,6 +23,7 @@ VWQ_HOST = "https://cloudreco.vuforia.com" +@beartype @RETRY_ON_TOO_MANY_REQUESTS def _wait_for_target_processed(vws_client: VWS, target_id: str) -> None: """Wait for a target to be processed. diff --git a/tests/mock_vws/fixtures/vuforia_backends.py b/tests/mock_vws/fixtures/vuforia_backends.py index 6f5ea90ba..d975546ac 100644 --- a/tests/mock_vws/fixtures/vuforia_backends.py +++ b/tests/mock_vws/fixtures/vuforia_backends.py @@ -29,6 +29,7 @@ LOGGER.setLevel(level=logging.DEBUG) +@beartype @RETRY_ON_TOO_MANY_REQUESTS def _delete_all_targets(*, database_keys: CloudDatabase) -> None: """Delete all targets. diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index de18b5bdb..c5decad57 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -8,6 +8,7 @@ from urllib.parse import urljoin import requests +from beartype import beartype from PIL import Image from requests.structures import CaseInsensitiveDict from vws.response import Response @@ -52,6 +53,7 @@ class Endpoint: access_key: str secret_key: str + @beartype def send(self) -> Response: """Send the request.""" request = requests.Request( @@ -81,6 +83,7 @@ def auth_header_content_type(self) -> str: return full_content_type.split(sep=";")[0] +@beartype def make_image_file( file_format: str, color_space: Literal["RGB", "CMYK"], diff --git a/tests/mock_vws/utils/assertions.py b/tests/mock_vws/utils/assertions.py index e026fed02..f0d132329 100644 --- a/tests/mock_vws/utils/assertions.py +++ b/tests/mock_vws/utils/assertions.py @@ -219,6 +219,7 @@ def assert_query_success(*, response: Response) -> None: ) +@beartype def assert_vwq_failure( *, response: Response, diff --git a/tests/mock_vws/utils/usage_test_helpers.py b/tests/mock_vws/utils/usage_test_helpers.py index 32d9231e2..708b1b168 100644 --- a/tests/mock_vws/utils/usage_test_helpers.py +++ b/tests/mock_vws/utils/usage_test_helpers.py @@ -3,12 +3,14 @@ import datetime import io +from beartype import beartype from vws import VWS from vws.reports import TargetStatuses from mock_vws.database import CloudDatabase +@beartype def processing_time_seconds( *, vuforia_database: CloudDatabase,