Repository: kedro-org/kedro
File: tests/config/test_omegaconf_config.py (Python)

Code before:
            str(tmp_path),
            config_patterns={"spark": ["spark*", "spark*/**", "**/spark*"]},
            runtime_params=runtime_params,
            base_env=_BASE_ENV,
            default_run_env=_DEFAULT_RUN_ENV,
        )
        parameters = conf["parameters"]
        catalog = conf["catalog"]
        credentials = conf["credentials"]
        spark = conf["spark"]

        assert key in parameters
        assert key not in catalog
        assert key not in credentials
        assert key not in spark

    def test_ignore_hidden_keys(self, tmp_path):
        """Check that the config key starting with `_` are ignored and also
        don't cause a config merge error"""
        _write_yaml(tmp_path / _BASE_ENV / "catalog1.yml", {"k1": "v1", "_k2": "v2"})
        _write_yaml(tmp_path / _BASE_ENV / "catalog2.yml", {"k3": "v3", "_k2": "v4"})

        conf = OmegaConfigLoader(
            str(tmp_path), base_env=_BASE_ENV, default_run_env=_DEFAULT_RUN_ENV
        )
        conf.default_run_env = ""
        catalog = conf["catalog"]
        assert catalog.keys() == {"k1", "k3"}

        _write_yaml(tmp_path / _BASE_ENV / "catalog3.yml", {"k1": "dup", "_k2": "v5"})
        pattern = (
            r"Duplicate keys found in "
            r"(.*catalog1\.yml and .*catalog3\.yml|.*catalog3\.yml and .*catalog1\.yml)"
            r"\: k1"
        )
        with pytest.raises(ValueError, match=pattern):
            conf["catalog"]

    def test_variable_interpolation_in_catalog_with_templates(self, tmp_path):
        base_catalog = tmp_path / _BASE_ENV / "catalog.yml"
        catalog_config = {
            "companies": {
                "type": "${_pandas.type}",
                "filepath": "data/01_raw/companies.csv",
            },
            "_pandas": {"type": "pandas.CSVDataset"},
        }
        _write_yaml(base_catalog, catalog_config)

        conf = OmegaConfigLoader(str(tmp_path), base_env=_BASE_ENV)
        assert conf["catalog"]["companies"]["type"] == "pandas.CSVDataset"

Review comment (suggestion):
```suggestion
        conf = OmegaConfigLoader(
            str(tmp_path), base_env=_BASE_ENV
        )
```

Code after:
            str(tmp_path),
            config_patterns={"spark": ["spark*", "spark*/**", "**/spark*"]},
            runtime_params=runtime_params,
            base_env=_BASE_ENV,
            default_run_env=_DEFAULT_RUN_ENV,
        )
        parameters = conf["parameters"]
        catalog = conf["catalog"]
        credentials = conf["credentials"]
        spark = conf["spark"]

        assert key in parameters
        assert key not in catalog
        assert key not in credentials
        assert key not in spark

    def test_ignore_hidden_keys(self, tmp_path):
        """Check that the config key starting with `_` are ignored and also
        don't cause a config merge error"""
        _write_yaml(tmp_path / _BASE_ENV / "catalog1.yml", {"k1": "v1", "_k2": "v2"})
        _write_yaml(tmp_path / _BASE_ENV / "catalog2.yml", {"k3": "v3", "_k2": "v4"})

        conf = OmegaConfigLoader(str(tmp_path), base_env=_BASE_ENV)
        catalog = conf["catalog"]
        assert catalog.keys() == {"k1", "k3"}

        _write_yaml(tmp_path / _BASE_ENV / "catalog3.yml", {"k1": "dup", "_k2": "v5"})
        pattern = (
            r"Duplicate keys found in "
            r"(.*catalog1\.yml and .*catalog3\.yml|.*catalog3\.yml and .*catalog1\.yml)"
            r"\: k1"
        )
        with pytest.raises(ValueError, match=pattern):
            conf["catalog"]

    def test_variable_interpolation_in_catalog_with_templates(self, tmp_path):
        base_catalog = tmp_path / _BASE_ENV / "catalog.yml"
        catalog_config = {
            "companies": {
                "type": "${_pandas.type}",
                "filepath": "data/01_raw/companies.csv",
            },
            "_pandas": {"type": "pandas.CSVDataset"},
        }
        _write_yaml(base_catalog, catalog_config)

        conf = OmegaConfigLoader(str(tmp_path), base_env=_BASE_ENV)
        assert conf["catalog"]["companies"]["type"] == "pandas.CSVDataset"

    def test_variable_interpolation_in_catalog_with_separate_templates_file(
        self, tmp_path