Skip to content

Add a default value to CallInfo.result #3560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2018

Conversation

alanbato
Copy link
Member

Fixes #3554

Any comments/questions welcome :)

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Great, thanks @alanbato!

I added some formatting to the CHANGELOG entry, after CI passes this is good to merge IMHO.

@coveralls
Copy link

coveralls commented Jun 10, 2018

Coverage Status

Coverage increased (+0.03%) to 92.732% when pulling 198e993 on alanbato:fix_callinfo_rrp into 7c8d072 on pytest-dev:master.

@alanbato alanbato merged commit 80f8a3a into pytest-dev:master Jun 10, 2018
@alanbato
Copy link
Member Author

Thanks @nicoddemus!

@alanbato alanbato deleted the fix_callinfo_rrp branch June 10, 2018 04:21
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

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

This is a breaking change, it has to be reverted

@nicoddemus
Copy link
Member

nicoddemus commented Jun 10, 2018

Is CallInfo an external API? What breaks by this change?

@nicoddemus
Copy link
Member

@RonnyPfannschmidt is right, indeed it is used by:

  • pytest_runtest_makereport(item, call)
  • pytest_exception_interact(node, call, report)

Someone might be checking hasattr(call, 'result') to check if the call succeeded.

I will open a PR to revert this from master shortly. I think it is OK to move this to features though?

nicoddemus added a commit to nicoddemus/pytest that referenced this pull request Jun 10, 2018
As discussed in pytest-dev#3560, this should not go to master because this breaks
the API.

Reverts commits:

1a7dcd7
198e993
@nicoddemus
Copy link
Member

nicoddemus commented Jun 10, 2018

Opened #3562, thanks @RonnyPfannschmidt for catching my slip up

@RonnyPfannschmidt
Copy link
Member

AS per original issue callinfo needs a New state, something Like pre-call

@nicoddemus
Copy link
Member

AS per original issue callinfo needs a New state, something Like pre-call

I see, because result = None is a valid function return value. But you propose to update __repr__ to handle this "new state" then?

@RonnyPfannschmidt
Copy link
Member

yes

@nicoddemus
Copy link
Member

Agreed. @alanbato want to tackle that?

@alanbato
Copy link
Member Author

Sure! Just to be sure though, do we want to include a new attribute that represents the different states? Something like CallInfo.is_finished. Or just do not has_attr(self, result) in the __repr__ func to print a different version of the repr string?

@RonnyPfannschmidt
Copy link
Member

@alanbato i beleive a getattr(self, 'result', NOTSET) followed by an is check is helpful there

NOTSET is defined in compat.py, and im thinking switching to attr.NOTHING in the long term

@nicoddemus
Copy link
Member

@RonnyPfannschmidt sounds good. I think the same check must be done for excinfo, I think it is also set only when an exception occurs.

@RonnyPfannschmidt
Copy link
Member

@nicoddemus that one is None at the class level

@nicoddemus
Copy link
Member

Oh OK, thanks

@blueyed
Copy link
Contributor

blueyed commented Aug 30, 2018

This was reverted in #3562 - what is the plan for it?

@RonnyPfannschmidt
Copy link
Member

well, i outlined the requirements for a correct fix above

@blueyed
Copy link
Contributor

blueyed commented Sep 11, 2018

@alanbato
Do you still plan to create a new PR?

blueyed added a commit to blueyed/pytest that referenced this pull request Nov 13, 2018
blueyed added a commit to blueyed/pytest that referenced this pull request Nov 13, 2018
blueyed added a commit to blueyed/pytest that referenced this pull request Nov 13, 2018
@blueyed
Copy link
Contributor

blueyed commented Nov 13, 2018

New attempt in #4381.

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.

5 participants