Skip to content

Include keyword-only defaults in step parameters - #934

Open
taltal-beep wants to merge 1 commit into
allure-framework:masterfrom
taltal-beep:fix/step-keyword-only-defaults
Open

taltal-beep wants to merge 1 commit into
allure-framework:masterfrom
taltal-beep:fix/step-keyword-only-defaults

Conversation

@taltal-beep

Copy link
Copy Markdown

Requested by Taltal

Context

func_parameters() collects the defaults of positional parameters but not of keyword-only ones. So with

@allure.step("Wait up to {timeout} seconds")
def wait(*, timeout=5): ...

calling wait() raises KeyError: 'timeout' from the step decorator and the test ends up broken, and even without a placeholder the parameter is missing from the step's parameters in the report. Positional defaults have been included since #440/#227.

The fix adds kwonlyargs to the parameter order and kwonlydefaults to the collected values; explicitly passed keywords still win.

Note: #910 builds a separate defaults map for the step title from arg_spec.defaults and would need the same handling.

Checklist

func_parameters() collected defaults of positional parameters only, so a
keyword-only parameter left at its default was missing from the step
parameters, and a step title placeholder referring to it raised KeyError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant