Skip to content

Commit 92ad123

Browse files
committed
fix(sqlserver): defer yaml import and skip scenario registration when config absent
In tests/providers/scenarios.py: - Move 'import yaml' inside _load_scenarios_from_config() so missing PyYAML does not break module import when scenarios are unused. - When the scenarios config file is missing, print a friendly skip notice and return instead of raising FileNotFoundError, allowing providers/registry import to succeed without a configured environment.
1 parent 5214fe5 commit 92ad123

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

‎tests/providers/scenarios.py‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,19 @@ def get_enabled_scenarios() -> Dict[str, Any]:
2525

2626

2727
def _load_scenarios_from_config():
28-
import yaml
29-
3028
env_config_path = os.getenv("SQLSERVER_SCENARIOS_CONFIG_PATH")
3129
if env_config_path and os.path.exists(env_config_path):
3230
print(f"Loading SQL Server scenarios from environment-specified path: {env_config_path}")
3331
config_path = env_config_path
3432
else:
3533
config_path = os.path.join(os.path.dirname(__file__), "..", "config", "sqlserver_scenarios.yaml")
3634
if not os.path.exists(config_path):
37-
raise FileNotFoundError(
38-
"No SQL Server scenarios configuration file found. "
39-
"Either set SQLSERVER_SCENARIOS_CONFIG_PATH environment variable "
40-
"or place sqlserver_scenarios.yaml in the tests/config directory."
41-
)
35+
print("No SQL Server scenarios configuration file found. Skipping scenario registration.")
36+
return
4237
print(f"Loading SQL Server scenarios from default path: {config_path}")
4338

4439
try:
40+
import yaml
4541
with open(config_path, 'r', encoding='utf-8') as f:
4642
config_data = yaml.safe_load(f)
4743

0 commit comments

Comments
 (0)