Skip to content

Commit 5f6b8ef

Browse files
committed
Decorate pytest fixtures correctly with beartype
1 parent b068511 commit 5f6b8ef

File tree

6 files changed

+25
-6
lines changed

6 files changed

+25
-6
lines changed

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import uuid
99

1010
import pytest
11+
from beartype import beartype
1112
from vws import VWS, CloudRecoService
1213

1314
from mock_vws.database import VuforiaDatabase
@@ -20,6 +21,7 @@
2021
]
2122

2223

24+
@beartype
2325
@pytest.fixture(name="vws_client")
2426
def fixture_vws_client(vuforia_database: VuforiaDatabase) -> VWS:
2527
"""
@@ -31,6 +33,7 @@ def fixture_vws_client(vuforia_database: VuforiaDatabase) -> VWS:
3133
)
3234

3335

36+
@beartype
3437
@pytest.fixture
3538
def cloud_reco_client(vuforia_database: VuforiaDatabase) -> CloudRecoService:
3639
"""
@@ -42,6 +45,7 @@ def cloud_reco_client(vuforia_database: VuforiaDatabase) -> CloudRecoService:
4245
)
4346

4447

48+
@beartype
4549
@pytest.fixture(name="inactive_vws_client")
4650
def fixture_inactive_vws_client(inactive_database: VuforiaDatabase) -> VWS:
4751
"""
@@ -53,6 +57,7 @@ def fixture_inactive_vws_client(inactive_database: VuforiaDatabase) -> VWS:
5357
)
5458

5559

60+
@beartype
5661
@pytest.fixture
5762
def inactive_cloud_reco_client(
5863
inactive_database: VuforiaDatabase,
@@ -66,6 +71,7 @@ def inactive_cloud_reco_client(
6671
)
6772

6873

74+
@beartype
6975
@pytest.fixture
7076
def target_id(
7177
image_file_success_state_low_rating: io.BytesIO,
@@ -85,6 +91,7 @@ def target_id(
8591
)
8692

8793

94+
@beartype
8895
@pytest.fixture(
8996
params=[
9097
"add_target",
@@ -106,6 +113,7 @@ def endpoint(request: pytest.FixtureRequest) -> Endpoint:
106113
return endpoint_fixture
107114

108115

116+
@beartype
109117
@pytest.fixture(
110118
params=[
111119
pytest.param(
@@ -140,6 +148,7 @@ def not_base64_encoded_processable(request: pytest.FixtureRequest) -> str:
140148
return not_base64_encoded_string
141149

142150

151+
@beartype
143152
@pytest.fixture(
144153
params=[
145154
pytest.param(

tests/mock_vws/fixtures/credentials.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class _InactiveVuforiaDatabaseSettings(_VuforiaDatabaseSettings):
3838
)
3939

4040

41-
@pytest.fixture
4241
@beartype
42+
@pytest.fixture
4343
def vuforia_database() -> VuforiaDatabase:
4444
"""
4545
Return VWS credentials from environment variables.
@@ -55,6 +55,7 @@ def vuforia_database() -> VuforiaDatabase:
5555
)
5656

5757

58+
@beartype
5859
@pytest.fixture
5960
def inactive_database() -> VuforiaDatabase:
6061
"""

tests/mock_vws/fixtures/prepared_requests.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def _wait_for_target_processed(vws_client: VWS, target_id: str) -> None:
3838
vws_client.wait_for_target_processed(target_id=target_id)
3939

4040

41+
@beartype
4142
@pytest.fixture
4243
def add_target(
4344
vuforia_database: VuforiaDatabase,
@@ -96,6 +97,7 @@ def add_target(
9697
)
9798

9899

100+
@beartype
99101
@pytest.fixture
100102
def delete_target(
101103
vuforia_database: VuforiaDatabase,
@@ -145,6 +147,7 @@ def delete_target(
145147
)
146148

147149

150+
@beartype
148151
@pytest.fixture
149152
def database_summary(vuforia_database: VuforiaDatabase) -> Endpoint:
150153
"""
@@ -191,8 +194,8 @@ def database_summary(vuforia_database: VuforiaDatabase) -> Endpoint:
191194
)
192195

193196

194-
@pytest.fixture
195197
@beartype
198+
@pytest.fixture
196199
def get_duplicates(
197200
vuforia_database: VuforiaDatabase,
198201
target_id: str,
@@ -244,8 +247,8 @@ def get_duplicates(
244247
)
245248

246249

247-
@pytest.fixture
248250
@beartype
251+
@pytest.fixture
249252
def get_target(
250253
vuforia_database: VuforiaDatabase,
251254
target_id: str,
@@ -296,6 +299,7 @@ def get_target(
296299
)
297300

298301

302+
@beartype
299303
@pytest.fixture
300304
def target_list(vuforia_database: VuforiaDatabase) -> Endpoint:
301305
"""
@@ -342,6 +346,7 @@ def target_list(vuforia_database: VuforiaDatabase) -> Endpoint:
342346
)
343347

344348

349+
@beartype
345350
@pytest.fixture
346351
def target_summary(
347352
vuforia_database: VuforiaDatabase,
@@ -393,6 +398,7 @@ def target_summary(
393398
)
394399

395400

401+
@beartype
396402
@pytest.fixture
397403
def update_target(
398404
vuforia_database: VuforiaDatabase,
@@ -447,6 +453,7 @@ def update_target(
447453
)
448454

449455

456+
@beartype
450457
@pytest.fixture
451458
def query(
452459
vuforia_database: VuforiaDatabase,

tests/mock_vws/fixtures/vuforia_backends.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131

3232
@RETRY_ON_TOO_MANY_REQUESTS
33-
@beartype
3433
def _delete_all_targets(*, database_keys: VuforiaDatabase) -> None:
3534
"""
3635
Delete all targets.
@@ -229,6 +228,7 @@ def pytest_collection_modifyitems(
229228
item.add_marker(skip_docker_build_tests_marker)
230229

231230

231+
@beartype
232232
@pytest.fixture(
233233
params=list(VuforiaBackend),
234234
ids=[backend.value for backend in list(VuforiaBackend)],
@@ -268,6 +268,7 @@ def verify_mock_vuforia(
268268
)
269269

270270

271+
@beartype
271272
@pytest.fixture(
272273
params=[item for item in VuforiaBackend if item != VuforiaBackend.REAL],
273274
ids=[
@@ -277,7 +278,6 @@ def verify_mock_vuforia(
277278
]
278279
],
279280
)
280-
@beartype
281281
def mock_only_vuforia(
282282
request: pytest.FixtureRequest,
283283
vuforia_database: VuforiaDatabase,

tests/mock_vws/test_docker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def wait_for_health_check(container: Container) -> None:
5151
raise ValueError(error_message)
5252

5353

54-
@pytest.fixture(name="custom_bridge_network")
5554
@beartype
55+
@pytest.fixture(name="custom_bridge_network")
5656
def fixture_custom_bridge_network() -> Iterator[Network]:
5757
"""
5858
Yield a custom bridge network which containers can connect to.

tests/mock_vws/test_flask_app_usage.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pytest
1111
import requests
1212
import responses
13+
from beartype import beartype
1314
from PIL import Image
1415
from requests_mock_flask import add_flask_app_to_mock
1516
from vws import VWS, CloudRecoService
@@ -25,6 +26,7 @@
2526
_EXAMPLE_URL_FOR_TARGET_MANAGER = "http://" + uuid.uuid4().hex + ".com"
2627

2728

29+
@beartype
2830
@pytest.fixture(autouse=True)
2931
def _(monkeypatch: pytest.MonkeyPatch) -> Iterator[None]:
3032
"""

0 commit comments

Comments
 (0)