Repository: Bachmann1234/diff_cover

Issue:
why HTML&JSON reports are prohibited and why they cannot be generated at the same time
Want to know why HTML&JSON reports are prohibited and why they cannot be generated at the same time

`output_format = parser.add_mutually_exclusive_group()`

Discussion:
Bachmann1234: Thanks!

Patch:
diff --git a/diff_cover/diff_cover_tool.py b/diff_cover/diff_cover_tool.py
index 2894013..e74a453 100644
--- a/diff_cover/diff_cover_tool.py
+++ b/diff_cover/diff_cover_tool.py
@@ -60,9 +60,7 @@ def parse_coverage_args(argv):
 
     parser.add_argument("coverage_xml", type=str, help=COVERAGE_XML_HELP, nargs="+")
 
-    output_format = parser.add_mutually_exclusive_group()
-
-    output_format.add_argument(
+    parser.add_argument(
         "--html-report",
         metavar="FILENAME",
         type=str,
@@ -70,7 +68,7 @@ def parse_coverage_args(argv):
         help=HTML_REPORT_HELP,
     )
 
-    output_format.add_argument(
+    parser.add_argument(
         "--json-report",
         metavar="FILENAME",
         type=str,
@@ -78,7 +76,7 @@ def parse_coverage_args(argv):
         help=JSON_REPORT_HELP,
     )
 
-    output_format.add_argument(
+    parser.add_argument(
         "--markdown-report",
         metavar="FILENAME",
         type=str,
@@ -86,7 +84,7 @@ def parse_coverage_args(argv):
         help=MARKDOWN_REPORT_HELP,
     )
 
-    output_format.add_argument(
+    parser.add_argument(
         "--show-uncovered", action="store_true", default=False, help=SHOW_UNCOVERED
     )
 
@@ -199,12 +197,12 @@ def generate_coverage_report(
             with open(css_file, "wb") as output_file:
                 reporter.generate_css(output_file)
 
-    elif json_report is not None:
+    if json_report is not None:
         reporter = JsonReportGenerator(coverage, diff)
         with open(json_report, "wb") as output_file:
             reporter.generate_report(output_file)
 
-    elif markdown_report is not None:
+    if markdown_report is not None:
         reporter = MarkdownReportGenerator(coverage, diff)
         with open(markdown_report, "wb") as output_file:
             reporter.generate_report(output_file)


Test patch:
diff --git a/diff_cover/tests/test_diff_cover_tool.py b/diff_cover/tests/test_diff_cover_tool.py
index afe8f77..b6f26f7 100644
--- a/diff_cover/tests/test_diff_cover_tool.py
+++ b/diff_cover/tests/test_diff_cover_tool.py
@@ -7,27 +7,47 @@ from diff_cover.diff_cover_tool import parse_coverage_args
 
 def test_parse_with_html_report():
     argv = ["reports/coverage.xml", "--html-report", "diff_cover.html"]
-
     arg_dict = parse_coverage_args(argv)
 
     assert arg_dict.get("coverage_xml") == ["reports/coverage.xml"]
-
     assert arg_dict.get("html_report") == "diff_cover.html"
+    assert arg_dict.get("markdown_report") is None
+    assert arg_dict.get("json_report") is None
     assert not arg_dict.get("ignore_unstaged")
 
 
-def test_parse_with_no_html_report():
+def test_parse_with_no_report():
     argv = ["reports/coverage.xml"]
+    arg_dict = parse_coverage_args(argv)
+
+    assert arg_dict.get("coverage_xml") == ["reports/coverage.xml"]
+    assert arg_dict.get("html_report") is None
+    assert arg_dict.get("markdown_report") is None
+    assert arg_dict.get("json_report") is None
+    assert not arg_dict.get("ignore_unstaged")
 
+
+def test_parse_with_multiple_reports():
+    argv = [
+        "reports/coverage.xml",
+        "--html-report",
+        "report.html",
+        "--markdown-report",
+        "report.md",
+    ]
     arg_dict = parse_coverage_args(argv)
+
     assert arg_dict.get("coverage_xml") == ["reports/coverage.xml"]
+    assert arg_dict.get("html_report") == "report.html"
+    assert arg_dict.get("markdown_report") == "report.md"
+    assert arg_dict.get("json_report") is None
     assert not arg_dict.get("ignore_unstaged")
 
 
 def test_parse_with_ignored_unstaged():
     argv = ["reports/coverage.xml", "--ignore-unstaged"]
-
     arg_dict = parse_coverage_args(argv)
+
     assert arg_dict.get("ignore_unstaged")
 
 
@@ -46,11 +66,9 @@ def test_parse_with_exclude():
     assert arg_dict.get("exclude") is None
 
     argv = ["reports/coverage.xml", "--exclude", "noneed/*.py"]
-
     arg_dict = parse_coverage_args(argv)
     assert arg_dict.get("exclude") == ["noneed/*.py"]
 
     argv = ["reports/coverage.xml", "--exclude", "noneed/*.py", "other/**/*.py"]
-
     arg_dict = parse_coverage_args(argv)
     assert arg_dict.get("exclude") == ["noneed/*.py", "other/**/*.py"]