From 84a4306cb663c5d755a62f23048b5c36affd16dc Mon Sep 17 00:00:00 2001 From: Paul Van Eck <paulvaneck@microsoft.com> Date: Wed, 14 Sep 2022 16:17:03 -0700 Subject: [PATCH] [Test Proxy] Update environment_variables scope (#26076) This updates the environment_variables pytest fixture scope to "session" (as opposed to the default "function" scope) in order to enable users to use it in other session scoped fixtures. Also, for most cases users will only need one instance of EnvironmentVariableSanitizer per test session since the envars won't typically change during the test run. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com> --- tools/azure-sdk-tools/devtools_testutils/proxy_fixtures.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/azure-sdk-tools/devtools_testutils/proxy_fixtures.py b/tools/azure-sdk-tools/devtools_testutils/proxy_fixtures.py index c6733be223f8..2d553c646544 100644 --- a/tools/azure-sdk-tools/devtools_testutils/proxy_fixtures.py +++ b/tools/azure-sdk-tools/devtools_testutils/proxy_fixtures.py @@ -94,10 +94,13 @@ def get_or_record(self, variable: str, default: str) -> str: return self.variables.setdefault(variable, default) -@pytest.fixture +@pytest.fixture(scope="session") def environment_variables(test_proxy: None) -> EnvironmentVariableSanitizer: """Fixture that returns an EnvironmentVariableSanitizer for convenient environment variable fetching and sanitizing. + This fixture is session-scoped, so a single instance of EnvironmentVariableSanitizer is shared across all + tests using this fixture in the test session. + :param test_proxy: The fixture responsible for starting up the test proxy server. :type test_proxy: None