Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 912fda8

Browse files
marcosdotmeLee-W
authored andcommitted
test: extend tests for 'TestJsonConfig' and 'TestYamlConfig'
1 parent 4bf8ca6 commit 912fda8

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

‎tests/test_conf.py‎

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,35 +255,53 @@ def test_init_with_invalid_config_content(
255255
config.TomlConfig(data=existing_content, path=path)
256256

257257

258+
@pytest.mark.parametrize(
259+
"config_file, exception_string",
260+
[
261+
(".cz.json", r"\.cz\.json"),
262+
("cz.json", r"cz\.json"),
263+
],
264+
ids=[".cz.json", "cz.json"],
265+
)
258266
class TestJsonConfig:
259-
def test_init_empty_config_content(self, tmpdir):
260-
path = tmpdir.mkdir("commitizen").join(".cz.json")
267+
def test_init_empty_config_content(self, tmpdir, config_file, exception_string):
268+
path = tmpdir.mkdir("commitizen").join(config_file)
261269
json_config = config.JsonConfig(data="{}", path=path)
262270
json_config.init_empty_config_content()
263271

264272
with open(path, encoding="utf-8") as json_file:
265273
assert json.load(json_file) == {"commitizen": {}}
266274

267-
def test_init_with_invalid_config_content(self, tmpdir):
275+
def test_init_with_invalid_config_content(
276+
self, tmpdir, config_file, exception_string
277+
):
268278
existing_content = "invalid json content"
269-
path = tmpdir.mkdir("commitizen").join(".cz.json")
279+
path = tmpdir.mkdir("commitizen").join(config_file)
270280

271-
with pytest.raises(InvalidConfigurationError, match=r"\.cz\.json"):
281+
with pytest.raises(InvalidConfigurationError, match=exception_string):
272282
config.JsonConfig(data=existing_content, path=path)
273283

274284

285+
@pytest.mark.parametrize(
286+
"config_file, exception_string",
287+
[
288+
(".cz.yaml", r"\.cz\.yaml"),
289+
("cz.yaml", r"cz\.yaml"),
290+
],
291+
ids=[".cz.yaml", "cz.yaml"],
292+
)
275293
class TestYamlConfig:
276-
def test_init_empty_config_content(self, tmpdir):
277-
path = tmpdir.mkdir("commitizen").join(".cz.yaml")
294+
def test_init_empty_config_content(self, tmpdir, config_file, exception_string):
295+
path = tmpdir.mkdir("commitizen").join(config_file)
278296
yaml_config = config.YAMLConfig(data="{}", path=path)
279297
yaml_config.init_empty_config_content()
280298

281299
with open(path) as yaml_file:
282300
assert yaml.safe_load(yaml_file) == {"commitizen": {}}
283301

284-
def test_init_with_invalid_content(self, tmpdir):
302+
def test_init_with_invalid_content(self, tmpdir, config_file, exception_string):
285303
existing_content = "invalid: .cz.yaml: content: maybe?"
286-
path = tmpdir.mkdir("commitizen").join(".cz.yaml")
304+
path = tmpdir.mkdir("commitizen").join(config_file)
287305

288-
with pytest.raises(InvalidConfigurationError, match=r"\.cz\.yaml"):
306+
with pytest.raises(InvalidConfigurationError, match=exception_string):
289307
config.YAMLConfig(data=existing_content, path=path)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /