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

gh-106368: Argument clinic: improve coverage for self.valid_line() calls#107641
AlexWaygood merged 1 commit into
python:mainfrom
AlexWaygood:valid-line-coverage

Conversation

@AlexWaygood

@AlexWaygoodAlexWaygood 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:

ifnotself.valid_line(line):
return

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

defstate_function_docstring(self, line: str) ->None:
assertself.functionisnotNone
ifself.group:
fail(f"Function {self.function.name!r} has a ']' without a matching '['.")
ifnotself.valid_line(line):
return

defstate_parameter_docstring(self, line: str) ->None:
ifnotself.valid_line(line):
return

Add a test that covers both of them.

@erlend-aaslanderlend-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:mainAug 4, 2023
@AlexWaygood
AlexWaygood deleted the valid-line-coverage branch August 4, 2023 19:41
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@AlexWaygood@erlend-aasland@bedevere-bot