GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — @allure.step decorator fails if one of the method parameters has a default value · Issue #440 · allure-framework/allure-python

@allure.step decorator fails if one of the method parameters has a default value #440

New issue
Copy link
New issue
Copy link
Closed
#569
Closed
@allure.step decorator fails if one of the method parameters has a default value#440
#569
Copy link

Description

@tanistra
tanistra
opened on Oct 31, 2019
Issue body actions

I have a method that has the default argument set to "None". (it can be string as well)

@allure.step(
    "Send message: '{message}' on {channel} with props: '{props}'")
def send_message(
        self,
        channel: str,
        message: str,
        username: str = None,
        props: Dict = None) -> None:
    ...

Calling this method without the props parameter:

self.bot.send_message(
       channel=self.DZIUNIA['mm_channel_id'],
       message=letter)

causes a Python exception:

E KeyError: 'props'

Activity

  1. mlewandowskipear commented on Oct 31, 2019

    @mlewandowskipear
    mlewandowskipear
    on Oct 31, 2019
    More actions

    I have seen this too.
    I assume the hook doesn't get a 'props' in this case, therefore fails. Yet, the function would be the next step after the hook, where it forces props = None making it a known variable.

    Not sure if it's a bug, or working as intended, due to order of operations.
    To that end, my workaround would be using a context manager for the whole step:

    def send_message(
            self,
            channel: str,
            message: str,
            username: str = None,
            props: Dict = None) -> None:
         with allure.step(
            "Send message: '{message}' on {channel} with props: '{props}'")
            <code>
    

    Hope that helps for the mean time!

  2. tanistra commented on Oct 31, 2019

    @tanistra
    tanistra
    on Oct 31, 2019
    Author
    More actions

    I don't know if it's a bug either.

    I will try to replace decorator by your solution.

    Thanks!

  3. ocherniavskyi-lohika-tix commented on Feb 20, 2020

    @ocherniavskyi-lohika-tix
    ocherniavskyi-lohika-tix
    on Feb 20, 2020
    More actions

    image
    The problem is here - in this case only kwargs will be treated as a parameters
    But actually we need to take all default parameters from function object and merge them with kwargs

  4. Araksya-Hambaryan commented on May 25, 2020

    @Araksya-Hambaryan
    Araksya-Hambaryan
    on May 25, 2020
    More actions

    Is there any updates?
    Please note that the issue occurs on 2.8.15 version as well

  5. Denis-Alexeev commented on Mar 3, 2021

    @Denis-Alexeev
    Denis-Alexeev
    on Mar 3, 2021
    Contributor
    More actions

    Is there any updates?
    Please note that the issue occurs on 2.8.15 version as well

    PR #569

  6. sseliverstov
    closed this as completedin #569on May 19, 2021
  7. sseliverstov
    added a commit that references this issue on May 19, 2021

    Add an ability to pass positional args as keyword (fixes #440) (#569)

    This issue will close once commit b2e64d4 is merged into the 'master' branch.
    b2e64d4
  8. beckerGil
    added a commit that references this issue on Apr 10, 2023

    Add an ability to pass positional args as keyword (fixes allure-frame…

    This issue will close once commit d21a2bf is merged into the 'master' branch.
    d21a2bf
  9. IvanBuruyane
    added a commit that references this issue on Mar 19, 2024

    Add an ability to pass positional args as keyword (fixes allure-frame…

    This issue will close once commit 6a59bea is merged into the 'master' branch.
    6a59bea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.