From 7d075b44d40ca1b5dcd0b0f375b0159b9ab1c53b Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 25 Apr 2024 08:16:32 -0400 Subject: [PATCH] fix: 'always true' is clearer than 'never false' --- CHANGES.rst | 3 +++ coverage/parser.py | 4 ++-- tests/gold/html/b_branch/b_py.html | 10 +++++----- tests/gold/html/partial/partial_py.html | 6 +++--- tests/gold/html/partial_626/partial_py.html | 8 ++++---- tests/test_html.py | 6 +++--- tests/test_parser.py | 4 ++-- 7 files changed, 22 insertions(+), 19 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5369e29c1..74412bf53 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -27,6 +27,9 @@ Unreleased hashes added to their names to ensure updated files are used instead of stale cached copies. +- Missing branch coverage explanations that said "the condition was never + false" now read "was always true" because it's easier to understand. + .. scriv-start-here diff --git a/coverage/parser.py b/coverage/parser.py index 45ea397bb..8a64f6247 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -1093,7 +1093,7 @@ def _handle__If(self, node: ast.If) -> set[ArcStart]: start = self.line_for_node(node.test) from_start = ArcStart(start, cause="the condition on line {lineno} was never true") exits = self.add_body_arcs(node.body, from_start=from_start) - from_start = ArcStart(start, cause="the condition on line {lineno} was never false") + from_start = ArcStart(start, cause="the condition on line {lineno} was always true") exits |= self.add_body_arcs(node.orelse, from_start=from_start) return exits @@ -1287,7 +1287,7 @@ def _handle__While(self, node: ast.While) -> set[ArcStart]: my_block = self.block_stack.pop() assert isinstance(my_block, LoopBlock) exits.update(my_block.break_exits) - from_start = ArcStart(start, cause="the condition on line {lineno} was never false") + from_start = ArcStart(start, cause="the condition on line {lineno} was always true") if node.orelse: else_exits = self.add_body_arcs(node.orelse, from_start=from_start) exits |= else_exits diff --git a/tests/gold/html/b_branch/b_py.html b/tests/gold/html/b_branch/b_py.html index dbda3ea29..5bbd60cda 100644 --- a/tests/gold/html/b_branch/b_py.html +++ b/tests/gold/html/b_branch/b_py.html @@ -67,7 +67,7 @@

» next       coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 08:04 -0400