Skip to content

Making _CallOutcome.result private in 3.0 #1572

Closed

Description

@The-Compiler

I propose to rename pluggy._CallOutcome.result to _result with pytest 3.0. It seems to be a common mistake to use .result instead of get_result():

If there was an exception in the wrapped hook, the result attribute will not exist at all, which will cause an AttributeError which hides the exception which actually happened.

To avoid that mistake, I think it'd be better to only use the attribute internally and only provide get_result as external API.

Activity

  1. RonnyPfannschmidt commented on May 31, 2016

    @RonnyPfannschmidt
    Member

    please report against pluggy

    i think we could get by by creating a non-data descriptor that raises the actual exception from the actual traceback when used

    (non-data descriptors get only triggered if the instance does not have an attribute of the same name)

  2. The-Compiler commented on May 31, 2016

    @The-Compiler
    MemberAuthor

    I reported it here because it'll be a backwards compatibility break in pytest and mainly affect pytest code and users 😉

    I guess that'd work as well, but it strikes me as quite weird that an attribute access would raise a (non-AttributeError) exception.

  3. RonnyPfannschmidt commented on May 31, 2016

    @RonnyPfannschmidt
    Member

    i think a nice way to solve this is to make get_result use _result and to have result as a alias property for get_result

  4. nicoddemus commented on May 31, 2016

    @nicoddemus
    Member

    I like @RonnyPfannschmidt's idea. 😁

    I also have been bitten by this issue myself.

  5. nicoddemus commented on Sep 14, 2017

    @nicoddemus
    Member

    This has been changed already on pluggy, but will become again a read-only property that calls get_result() under the covers in pytest-dev/pluggy#88.

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

    type: backward compatibilitymight present some backward compatibility issues which should be carefully noted in the changelog

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions