@@ -248,18 +248,24 @@ value of `"appId"`, and `AZURE_CLIENT_SECRET` to the value of `"password"`.
248
248
The test proxy has to be available in order for tests to work; this is done automatically with a ` pytest ` fixture.
249
249
250
250
Create a ` conftest.py ` file within your package's test directory (` sdk/{service}/{package}/tests ` ), and inside it add a
251
- session-level fixture that accepts ` devtools_testutils. test_proxy` as a parameter (and has ` autouse ` set to ` True ` ):
251
+ session-level fixture that accepts the ` test_proxy ` fixture as a parameter (and has ` autouse ` set to ` True ` ):
252
252
253
253
``` python
254
254
import pytest
255
- from devtools_testutils import test_proxy
256
255
257
256
# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method
257
+ # test_proxy auto-starts the test proxy
258
+ # patch_sleep and patch_async_sleep streamline tests by disabling wait times during LRO polling
258
259
@pytest.fixture (scope = " session" , autouse = True )
259
- def start_proxy (test_proxy ):
260
+ def start_proxy (test_proxy , patch_sleep , patch_async_sleep ):
260
261
return
261
262
```
262
263
264
+ As shown in the example, it's recommended to also request the ` patch_sleep ` and ` patch_async_sleep ` fixtures unless
265
+ your tests have a unique need to use ` time.sleep ` or ` asyncio.sleep ` during playback tests (this is unusual). All of
266
+ these fixtures are imported by the central [ ` /sdk/conftest.py ` ] [ central_conftest ] , so ` pytest ` will automatically
267
+ resolve the references.
268
+
263
269
For more details about how this fixture starts up the test proxy, or the test proxy itself, refer to the
264
270
[ test proxy migration guide] [ test_proxy_startup ] .
265
271
@@ -576,6 +582,7 @@ For information about more advanced testing scenarios, refer to the [advanced te
576
582
[ azure_cli_service_principal ] : https://docs.microsoft.com/cli/azure/ad/sp?view=azure-cli-latest#az-ad-sp-create-for-rbac
577
583
[ azure_portal ] : https://portal.azure.com/
578
584
[ azure_recorded_test_case ] : https://github.com/Azure/azure-sdk-for-python/blob/7e66e3877519a15c1d4304eb69abf0a2281773/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py#L44
585
+ [ central_conftest ] : https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/conftest.py
579
586
[ env_var_docs ] : https://github.com/Azure/azure-sdk-for-python/tree/main/tools/azure-sdk-tools/devtools_testutils#use-the-environmentvariableloader
580
587
[ env_var_loader ] : https://github.com/Azure/azure-sdk-for-python/blob/main/tools/azure-sdk-tools/devtools_testutils/envvariable_loader.py
581
588
[ generate_sas ] : https://github.com/Azure/azure-sdk-for-python/blob/bf4749babb363e2dc972775f4408036e31f361b4/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py#L196
0 commit comments