|
2 | 2 |
|
3 | 3 | from commitizen.cz.conventional_commits.conventional_commits import (
|
4 | 4 | ConventionalCommitsCz,
|
5 |
| - parse_scope, |
6 |
| - parse_subject, |
| 5 | + _parse_scope, |
| 6 | + _parse_subject, |
7 | 7 | )
|
8 | 8 | from commitizen.cz.exceptions import AnswerRequiredError
|
9 | 9 |
|
10 |
| -valid_scopes = ["", "simple", "dash-separated", "camelCaseUPPERCASE"] |
11 | 10 |
|
12 |
| -scopes_transformations = [["with spaces", "with-spaces"], [None, ""]] |
13 |
| - |
14 |
| -valid_subjects = ["this is a normal text", "aword"] |
15 |
| - |
16 |
| -subjects_transformations = [["with dot.", "with dot"]] |
17 |
| - |
18 |
| -invalid_subjects = ["", " ", ".", " .", "", None] |
19 |
| - |
20 |
| - |
21 |
| -def test_parse_scope_valid_values(): |
22 |
| - for valid_scope in valid_scopes: |
23 |
| - assert valid_scope == parse_scope(valid_scope) |
| 11 | +@pytest.mark.parametrize( |
| 12 | + "valid_scope", ["", "simple", "dash-separated", "camelCaseUPPERCASE"] |
| 13 | +) |
| 14 | +def test_parse_scope_valid_values(valid_scope): |
| 15 | + assert valid_scope == _parse_scope(valid_scope) |
24 | 16 |
|
25 | 17 |
|
26 |
| -def test_scopes_transformations(): |
27 |
| - for scopes_transformation in scopes_transformations: |
28 |
| - invalid_scope, transformed_scope = scopes_transformation |
29 |
| - assert transformed_scope == parse_scope(invalid_scope) |
| 18 | +@pytest.mark.parametrize( |
| 19 | + "scopes_transformation", [["with spaces", "with-spaces"], ["", ""]] |
| 20 | +) |
| 21 | +def test_scopes_transformations(scopes_transformation): |
| 22 | + invalid_scope, transformed_scope = scopes_transformation |
| 23 | + assert transformed_scope == _parse_scope(invalid_scope) |
30 | 24 |
|
31 | 25 |
|
32 |
| -def test_parse_subject_valid_values(): |
33 |
| - for valid_subject in valid_subjects: |
34 |
| - assert valid_subject == parse_subject(valid_subject) |
| 26 | +@pytest.mark.parametrize("valid_subject", ["this is a normal text", "aword"]) |
| 27 | +def test_parse_subject_valid_values(valid_subject): |
| 28 | + assert valid_subject == _parse_subject(valid_subject) |
35 | 29 |
|
36 | 30 |
|
37 |
| -def test_parse_subject_invalid_values(): |
38 |
| - for valid_subject in invalid_subjects: |
39 |
| - with pytest.raises(AnswerRequiredError): |
40 |
| - parse_subject(valid_subject) |
| 31 | +@pytest.mark.parametrize("invalid_subject", ["", " ", ".", " .", "\t\t."]) |
| 32 | +def test_parse_subject_invalid_values(invalid_subject): |
| 33 | + with pytest.raises(AnswerRequiredError): |
| 34 | + _parse_subject(invalid_subject) |
41 | 35 |
|
42 | 36 |
|
43 |
| -def test_subject_transformations(): |
44 |
| - for subject_transformation in subjects_transformations: |
45 |
| - invalid_subject, transformed_subject = subject_transformation |
46 |
| - assert transformed_subject == parse_subject(invalid_subject) |
| 37 | +@pytest.mark.parametrize("subject_transformation", [["with dot.", "with dot"]]) |
| 38 | +def test_subject_transformations(subject_transformation): |
| 39 | + invalid_subject, transformed_subject = subject_transformation |
| 40 | + assert transformed_subject == _parse_subject(invalid_subject) |
47 | 41 |
|
48 | 42 |
|
49 | 43 | def test_questions(config):
|
|
0 commit comments