From 133cfd49aebdc7b7e96428559d47fcd5e1066ec4 Mon Sep 17 00:00:00 2001 From: Asher Foa <1268088+asherf@users.noreply.github.com> Date: Thu, 16 Jul 2020 15:20:46 -0700 Subject: [PATCH] Don't turn on branch coverage by default. Follow up on https://github.com/pantsbuild/pants/pull/10289#discussion_r451901041 --- .../pants/backend/python/rules/coverage.py | 1 - .../python/rules/coverage_integration_test.py | 39 ++++++++++--------- .../backend/python/rules/coverage_test.py | 2 - 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/python/pants/backend/python/rules/coverage.py b/src/python/pants/backend/python/rules/coverage.py index 03bb127233ea..84ae4923e7c7 100644 --- a/src/python/pants/backend/python/rules/coverage.py +++ b/src/python/pants/backend/python/rules/coverage.py @@ -151,7 +151,6 @@ def _validate_and_update_config( ) -> None: if not coverage_config.has_section("run"): coverage_config.add_section("run") - coverage_config.set("run", "branch", "True") run_section = coverage_config["run"] relative_files_str = run_section.get("relative_files", "True") if relative_files_str.lower() != "true": diff --git a/src/python/pants/backend/python/rules/coverage_integration_test.py b/src/python/pants/backend/python/rules/coverage_integration_test.py index 30b770e1f1aa..4d40c9554d31 100644 --- a/src/python/pants/backend/python/rules/coverage_integration_test.py +++ b/src/python/pants/backend/python/rules/coverage_integration_test.py @@ -145,18 +145,18 @@ def test_coverage(self) -> None: assert ( dedent( f"""\ - Name Stmts Miss Branch BrPart Cover - ----------------------------------------------------------------------------------------------- - {tmpdir_relative}/src/python/project/__init__.py 0 0 0 0 100% - {tmpdir_relative}/src/python/project/lib.py 6 0 0 0 100% - {tmpdir_relative}/src/python/project/lib_test.py 3 0 0 0 100% - {tmpdir_relative}/tests/python/project_test/__init__.py 0 0 0 0 100% - {tmpdir_relative}/tests/python/project_test/no_src/__init__.py 0 0 0 0 100% - {tmpdir_relative}/tests/python/project_test/no_src/test_no_src.py 2 0 0 0 100% - {tmpdir_relative}/tests/python/project_test/test_arithmetic.py 3 0 0 0 100% - {tmpdir_relative}/tests/python/project_test/test_multiply.py 3 0 0 0 100% - ----------------------------------------------------------------------------------------------- - TOTAL 17 0 0 0 100% + Name Stmts Miss Cover + --------------------------------------------------------------------------------- + {tmpdir_relative}/src/python/project/__init__.py 0 0 100% + {tmpdir_relative}/src/python/project/lib.py 6 0 100% + {tmpdir_relative}/src/python/project/lib_test.py 3 0 100% + {tmpdir_relative}/tests/python/project_test/__init__.py 0 0 100% + {tmpdir_relative}/tests/python/project_test/no_src/__init__.py 0 0 100% + {tmpdir_relative}/tests/python/project_test/no_src/test_no_src.py 2 0 100% + {tmpdir_relative}/tests/python/project_test/test_arithmetic.py 3 0 100% + {tmpdir_relative}/tests/python/project_test/test_multiply.py 3 0 100% + --------------------------------------------------------------------------------- + TOTAL 17 0 100% """ ) in result.stderr_data @@ -169,16 +169,17 @@ def test_coverage_with_filter(self) -> None: result = self._run_tests( tmpdir_relative, "--coverage-py-filter=['project.lib', 'project_test.no_src']" ) + print(result.stderr_data) assert ( dedent( f"""\ - Name Stmts Miss Branch BrPart Cover - ----------------------------------------------------------------------------------------------- - {tmpdir_relative}/src/python/project/lib.py 6 0 0 0 100% - {tmpdir_relative}/tests/python/project_test/no_src/__init__.py 0 0 0 0 100% - {tmpdir_relative}/tests/python/project_test/no_src/test_no_src.py 2 0 0 0 100% - ----------------------------------------------------------------------------------------------- - TOTAL 8 0 0 0 100% + Name Stmts Miss Cover + --------------------------------------------------------------------------------- + {tmpdir_relative}/src/python/project/lib.py 6 0 100% + {tmpdir_relative}/tests/python/project_test/no_src/__init__.py 0 0 100% + {tmpdir_relative}/tests/python/project_test/no_src/test_no_src.py 2 0 100% + --------------------------------------------------------------------------------- + TOTAL 8 0 100% """ ) in result.stderr_data diff --git a/src/python/pants/backend/python/rules/coverage_test.py b/src/python/pants/backend/python/rules/coverage_test.py index 5e40b78e2991..38c54d11147d 100644 --- a/src/python/pants/backend/python/rules/coverage_test.py +++ b/src/python/pants/backend/python/rules/coverage_test.py @@ -53,7 +53,6 @@ def test_default_no_config(self) -> None: assert resolved_config == dedent( """\ [run] - branch = True relative_files = True omit = \ttest_runner.pex/* @@ -97,7 +96,6 @@ def test_config_no_run_section(self) -> None: ignore_errors = True [run] - branch = True relative_files = True omit = \ttest_runner.pex/*