@@ -689,9 +689,7 @@ def test_plan_apply_populates_cache(copy_to_temp_path, mocker):
689689 config_content = f .read ()
690690
691691 # Add cache_dir to the test_config definition
692- config_content = config_content .replace (
693- 'test_config = Config(\n gateways={"in_memory": GatewayConfig(connection=DuckDBConnectionConfig())},\n default_gateway="in_memory",\n plan=PlanConfig(\n auto_categorize_changes=CategorizerConfig(\n sql=AutoCategorizationMode.SEMI, python=AutoCategorizationMode.OFF\n )\n ),\n model_defaults=model_defaults,\n )' ,
694- f"""test_config = Config(
692+ config_content += f"""test_config_cache_dir = Config(
695693 gateways={{"in_memory": GatewayConfig(connection=DuckDBConnectionConfig())}},
696694 default_gateway="in_memory",
697695 plan=PlanConfig(
@@ -701,14 +699,14 @@ def test_plan_apply_populates_cache(copy_to_temp_path, mocker):
701699 ),
702700 model_defaults=model_defaults,
703701 cache_dir="{ custom_cache_dir .as_posix ()} ",
704- )""" ,
705- )
702+ before_all=before_all ,
703+ )"""
706704
707705 with open (config_py_path , "w" ) as f :
708706 f .write (config_content )
709707
710708 # Create context with the test config
711- context = Context (paths = sushi_path , config = "test_config " )
709+ context = Context (paths = sushi_path , config = "test_config_cache_dir " )
712710 custom_cache_dir = context .cache_dir
713711 assert "custom_cache" in str (custom_cache_dir )
714712 assert (custom_cache_dir / "optimized_query" ).exists ()
@@ -733,7 +731,7 @@ def test_plan_apply_populates_cache(copy_to_temp_path, mocker):
733731
734732 # New context should load same models and create the cache for optimized_query and model_definition
735733 initial_model_count = len (context .models )
736- context2 = Context (paths = context .path , config = "test_config " )
734+ context2 = Context (paths = context .path , config = "test_config_cache_dir " )
737735 cached_model_count = len (context2 .models )
738736
739737 assert initial_model_count == cached_model_count > 0
0 commit comments