|
44 | 44 | }
|
45 | 45 | }
|
46 | 46 |
|
| 47 | +JSON_STR = r""" |
| 48 | + { |
| 49 | + "commitizen": { |
| 50 | + "name": "cz_jira", |
| 51 | + "version": "1.0.0", |
| 52 | + "version_files": [ |
| 53 | + "commitizen/__version__.py", |
| 54 | + "pyproject.toml" |
| 55 | + ] |
| 56 | + } |
| 57 | + } |
| 58 | +""" |
| 59 | + |
| 60 | +YAML_STR = """ |
| 61 | +commitizen: |
| 62 | + name: cz_jira |
| 63 | + version: 1.0.0 |
| 64 | + version_files: |
| 65 | + - commitizen/__version__.py |
| 66 | + - pyproject.toml |
| 67 | +""" |
47 | 68 |
|
48 | 69 | _settings: dict[str, Any] = {
|
49 | 70 | "name": "cz_jira",
|
@@ -160,13 +181,30 @@ def test_load_empty_pyproject_toml_and_cz_toml_with_config(_, tmpdir):
|
160 | 181 |
|
161 | 182 | def test_load_pyproject_toml_not_in_root_folder(_, tmpdir):
|
162 | 183 | with tmpdir.as_cwd():
|
163 |
| - _not_root_path = tmpdir.mkdir("not_in_root") |
164 |
| - p = tmpdir.join("./not_in_root/pyproject.toml") |
165 |
| - p.write(PYPROJECT) |
| 184 | + _not_root_path = tmpdir.mkdir("not_in_root").join("pyproject.toml") |
| 185 | + _not_root_path.write(PYPROJECT) |
166 | 186 |
|
167 | 187 | cfg = config.read_cfg(filepath="./not_in_root/pyproject.toml")
|
168 | 188 | assert cfg.settings == _settings
|
169 | 189 |
|
| 190 | + def test_load_cz_json_not_in_root_folder(_, tmpdir): |
| 191 | + with tmpdir.as_cwd(): |
| 192 | + _not_root_path = tmpdir.mkdir("not_in_root").join(".cz.json") |
| 193 | + _not_root_path.write(JSON_STR) |
| 194 | + |
| 195 | + cfg = config.read_cfg(filepath="./not_in_root/.cz.json") |
| 196 | + json_cfg_by_class = config.JsonConfig(data=JSON_STR, path=_not_root_path) |
| 197 | + assert cfg.settings == json_cfg_by_class.settings |
| 198 | + |
| 199 | + def test_load_cz_yaml_not_in_root_folder(_, tmpdir): |
| 200 | + with tmpdir.as_cwd(): |
| 201 | + _not_root_path = tmpdir.mkdir("not_in_root").join(".cz.yaml") |
| 202 | + _not_root_path.write(YAML_STR) |
| 203 | + |
| 204 | + cfg = config.read_cfg(filepath="./not_in_root/.cz.yaml") |
| 205 | + yaml_cfg_by_class = config.YAMLConfig(data=JSON_STR, path=_not_root_path) |
| 206 | + assert cfg.settings == yaml_cfg_by_class._settings |
| 207 | + |
170 | 208 |
|
171 | 209 | class TestTomlConfig:
|
172 | 210 | def test_init_empty_config_content(self, tmpdir):
|
|
0 commit comments