From 14577b63026f147c5060c4dc67caed289219d5bd Mon Sep 17 00:00:00 2001 From: Daniel Fangl Date: Wed, 7 May 2025 15:14:05 +0200 Subject: [PATCH 1/2] Defer InfraProvisioner import in test fixture --- localstack-core/localstack/packages/api.py | 2 +- tests/aws/conftest.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/localstack-core/localstack/packages/api.py b/localstack-core/localstack/packages/api.py index 2ad3280e2d71c..bcc8add9577c5 100644 --- a/localstack-core/localstack/packages/api.py +++ b/localstack-core/localstack/packages/api.py @@ -8,7 +8,7 @@ from threading import RLock from typing import Any, Callable, Generic, List, Optional, ParamSpec, TypeVar -from plux import Plugin, PluginManager, PluginSpec # type: ignore[import-untyped] +from plux import Plugin, PluginManager, PluginSpec # type: ignore from localstack import config diff --git a/tests/aws/conftest.py b/tests/aws/conftest.py index c5c5612b76cef..319890e40c825 100644 --- a/tests/aws/conftest.py +++ b/tests/aws/conftest.py @@ -8,7 +8,6 @@ from localstack import config as localstack_config from localstack import constants -from localstack.testing.scenario.provisioning import InfraProvisioner from localstack.testing.snapshots.transformer_utility import ( SNAPSHOT_BASIC_TRANSFORMER, SNAPSHOT_BASIC_TRANSFORMER_NEW, @@ -85,6 +84,8 @@ def cdk_template_path(): # Note: Don't move this into testing lib @pytest.fixture(scope="session") def infrastructure_setup(cdk_template_path, aws_client): + from localstack.testing.scenario.provisioning import InfraProvisioner + def _infrastructure_setup( namespace: str, force_synth: Optional[bool] = False ) -> InfraProvisioner: From adc30c62fef523ff80c2aee6e2a7583b4c67300b Mon Sep 17 00:00:00 2001 From: Daniel Fangl Date: Wed, 7 May 2025 16:14:50 +0200 Subject: [PATCH 2/2] Add clarifying comment to deferred import --- tests/aws/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/aws/conftest.py b/tests/aws/conftest.py index 319890e40c825..3292bc6523de5 100644 --- a/tests/aws/conftest.py +++ b/tests/aws/conftest.py @@ -84,6 +84,7 @@ def cdk_template_path(): # Note: Don't move this into testing lib @pytest.fixture(scope="session") def infrastructure_setup(cdk_template_path, aws_client): + # Note: import needs to be local to avoid CDK import on every test run, which takes quite some time from localstack.testing.scenario.provisioning import InfraProvisioner def _infrastructure_setup(