Skip to content

Commit c6feed8

Browse files
authored
Fix --format with paths containing colons (#484)
* Fix --format with paths containing colons * Add test
1 parent 138f6d8 commit c6feed8

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

diff_cover/diff_cover_tool.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,11 @@
5656
def format_type(value):
5757
"""
5858
Accepts:
59-
--format html
60-
--format json
61-
--format json,html
62-
--format html,json:path/to/file.json
59+
--format html:path/to/file.html,json:path/to/file.json
6360
6461
return: dict of strings to paths
6562
"""
66-
return dict((item.split(":") for item in value.split(",")) if value else {})
63+
return dict((item.split(":", 1) for item in value.split(",")) if value else {})
6764

6865

6966
def parse_coverage_args(argv):

tests/test_diff_cover_tool.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ def test_parse_with_html_report():
1616
assert not arg_dict.get("ignore_unstaged")
1717

1818

19+
def test_report_path_with_colon():
20+
argv = [
21+
"reports/coverage.xml",
22+
"--format",
23+
"json:/this:path:should:work/without:breaking.json",
24+
]
25+
arg_dict = parse_coverage_args(argv)
26+
assert arg_dict.get("format") == {
27+
"json": "/this:path:should:work/without:breaking.json"
28+
}
29+
30+
1931
def test_parse_with_no_report():
2032
argv = ["reports/coverage.xml"]
2133
arg_dict = parse_coverage_args(argv)

0 commit comments

Comments
 (0)