Skip to content

gh-106368: Argument clinic: improve coverage for self.valid_line() calls - #107641

Merged
AlexWaygood merged 1 commit into
python:mainfrom
AlexWaygood:valid-line-coverage
Aug 4, 2023
Merged

AlexWaygood merged 1 commit into
python:mainfrom
AlexWaygood:valid-line-coverage

Conversation

@AlexWaygood

@AlexWaygood AlexWaygood commented Aug 4, 2023 •

Copy link
Copy Markdown
Member

The early return in self.state_modulename_name() is unreachable, as state_modulename_name() is only ever called from state_dsl_start, and the first thing state_dsl_start does is check whether the line is valid:

cpython/Tools/clinic/clinic.py

Lines 4655 to 4657 in 321f0f7

if not self.valid_line(line):
return

There are two other if not self.valid_line(line) branches in clinic.py which are reachable, but are uncovered:

cpython/Tools/clinic/clinic.py

Lines 5323 to 5330 in 321f0f7

def state_function_docstring(self, line: str) -> None:
assert self.function is not None
if self.group:
fail(f"Function {self.function.name!r} has a ']' without a matching '['.")
if not self.valid_line(line):
return

cpython/Tools/clinic/clinic.py

Lines 5304 to 5306 in 321f0f7

def state_parameter_docstring(self, line: str) -> None:
if not self.valid_line(line):
return

Add a test that covers both of them.

@erlend-aasland erlend-aasland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@AlexWaygood
AlexWaygood merged commit 2c25bd8 into python:main Aug 4, 2023
@AlexWaygood
AlexWaygood deleted the valid-line-coverage branch August 4, 2023 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants