Skip to content

Commit 640d8d1

Browse files
Merge pull request #3014 from VWS-Python/pytest-fixture-keyword-only-args
Use * for keyword-only arguments in pytest fixtures
2 parents 555a2d1 + 41d4100 commit 640d8d1

3 files changed

Lines changed: 25 additions & 9 deletions

File tree

tests/conftest.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
@pytest.fixture(name="vws_client")
25-
def fixture_vws_client(vuforia_database: CloudDatabase) -> VWS:
25+
def fixture_vws_client(*, vuforia_database: CloudDatabase) -> VWS:
2626
"""A VWS client for an active VWS database."""
2727
return VWS(
2828
server_access_key=vuforia_database.server_access_key,
@@ -31,7 +31,7 @@ def fixture_vws_client(vuforia_database: CloudDatabase) -> VWS:
3131

3232

3333
@pytest.fixture
34-
def cloud_reco_client(vuforia_database: CloudDatabase) -> CloudRecoService:
34+
def cloud_reco_client(*, vuforia_database: CloudDatabase) -> CloudRecoService:
3535
"""A query client for an active VWS database."""
3636
return CloudRecoService(
3737
client_access_key=vuforia_database.client_access_key,
@@ -40,7 +40,10 @@ def cloud_reco_client(vuforia_database: CloudDatabase) -> CloudRecoService:
4040

4141

4242
@pytest.fixture(name="inactive_vws_client")
43-
def fixture_inactive_vws_client(inactive_cloud_database: CloudDatabase) -> VWS:
43+
def fixture_inactive_vws_client(
44+
*,
45+
inactive_cloud_database: CloudDatabase,
46+
) -> VWS:
4447
"""A client for an inactive VWS database."""
4548
return VWS(
4649
server_access_key=inactive_cloud_database.server_access_key,
@@ -50,6 +53,7 @@ def fixture_inactive_vws_client(inactive_cloud_database: CloudDatabase) -> VWS:
5053

5154
@pytest.fixture
5255
def inactive_cloud_reco_client(
56+
*,
5357
inactive_cloud_database: CloudDatabase,
5458
) -> CloudRecoService:
5559
"""A query client for an inactive VWS database."""
@@ -61,6 +65,7 @@ def inactive_cloud_reco_client(
6165

6266
@pytest.fixture
6367
def target_id(
68+
*,
6469
image_file_success_state_low_rating: io.BytesIO,
6570
vws_client: VWS,
6671
) -> str:
@@ -91,7 +96,7 @@ def target_id(
9196
"vumark_generate_instance",
9297
],
9398
)
94-
def endpoint(request: pytest.FixtureRequest) -> Endpoint:
99+
def endpoint(*, request: pytest.FixtureRequest) -> Endpoint:
95100
"""
96101
Return details of an endpoint for the Target API or the Query
97102
API.
@@ -120,7 +125,7 @@ def endpoint(request: pytest.FixtureRequest) -> Endpoint:
120125
),
121126
],
122127
)
123-
def not_base64_encoded_processable(request: pytest.FixtureRequest) -> str:
128+
def not_base64_encoded_processable(*, request: pytest.FixtureRequest) -> str:
124129
"""Return a string which is not decodable as base64 data, but Vuforia
125130
will
126131
respond as if this is valid base64 data.
@@ -144,7 +149,10 @@ def not_base64_encoded_processable(request: pytest.FixtureRequest) -> str:
144149
pytest.param('"', id="Not a base64 character."),
145150
],
146151
)
147-
def not_base64_encoded_not_processable(request: pytest.FixtureRequest) -> str:
152+
def not_base64_encoded_not_processable(
153+
*,
154+
request: pytest.FixtureRequest,
155+
) -> str:
148156
"""
149157
Return a string which is not decodable as base64 data, and Vuforia
150158
will

tests/mock_vws/fixtures/prepared_requests.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def _wait_for_target_processed(*, vws_client: VWS, target_id: str) -> None:
3939

4040
@pytest.fixture
4141
def add_target(
42+
*,
4243
vuforia_database: CloudDatabase,
4344
image_file_failed_state: io.BytesIO,
4445
) -> Endpoint:
@@ -93,6 +94,7 @@ def add_target(
9394

9495
@pytest.fixture
9596
def delete_target(
97+
*,
9698
vuforia_database: CloudDatabase,
9799
target_id: str,
98100
vws_client: VWS,
@@ -136,7 +138,7 @@ def delete_target(
136138

137139

138140
@pytest.fixture
139-
def database_summary(vuforia_database: CloudDatabase) -> Endpoint:
141+
def database_summary(*, vuforia_database: CloudDatabase) -> Endpoint:
140142
"""
141143
Return details of the endpoint for getting details about the
142144
database.
@@ -180,6 +182,7 @@ def database_summary(vuforia_database: CloudDatabase) -> Endpoint:
180182

181183
@pytest.fixture
182184
def get_duplicates(
185+
*,
183186
vuforia_database: CloudDatabase,
184187
target_id: str,
185188
vws_client: VWS,
@@ -228,6 +231,7 @@ def get_duplicates(
228231

229232
@pytest.fixture
230233
def get_target(
234+
*,
231235
vuforia_database: CloudDatabase,
232236
target_id: str,
233237
vws_client: VWS,
@@ -272,7 +276,7 @@ def get_target(
272276

273277

274278
@pytest.fixture
275-
def target_list(vuforia_database: CloudDatabase) -> Endpoint:
279+
def target_list(*, vuforia_database: CloudDatabase) -> Endpoint:
276280
"""Return details of the endpoint for getting a list of targets."""
277281
date = rfc_1123_date()
278282
request_path = "/targets"
@@ -313,6 +317,7 @@ def target_list(vuforia_database: CloudDatabase) -> Endpoint:
313317

314318
@pytest.fixture
315319
def target_summary(
320+
*,
316321
vuforia_database: CloudDatabase,
317322
target_id: str,
318323
vws_client: VWS,
@@ -361,6 +366,7 @@ def target_summary(
361366

362367
@pytest.fixture
363368
def update_target(
369+
*,
364370
vuforia_database: CloudDatabase,
365371
target_id: str,
366372
vws_client: VWS,
@@ -409,6 +415,7 @@ def update_target(
409415

410416
@pytest.fixture
411417
def query(
418+
*,
412419
vuforia_database: CloudDatabase,
413420
high_quality_image: io.BytesIO,
414421
) -> Endpoint:
@@ -459,6 +466,7 @@ def query(
459466

460467
@pytest.fixture
461468
def vumark_generate_instance(
469+
*,
462470
vumark_vuforia_database: VuMarkCloudDatabase,
463471
) -> Endpoint:
464472
"""Return details of the endpoint for generating a VuMark instance."""

tests/mock_vws/test_flask_app_usage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434

3535
@pytest.fixture(autouse=True)
36-
def _(monkeypatch: pytest.MonkeyPatch) -> Iterator[None]:
36+
def _(*, monkeypatch: pytest.MonkeyPatch) -> Iterator[None]:
3737
"""Enable a mock service backed by the Flask applications."""
3838
with responses.RequestsMock(
3939
assert_all_requests_are_fired=False,

0 commit comments

Comments
 (0)