Skip to content

Conversation

bluetech
Copy link
Member

@bluetech bluetech commented Jul 1, 2020

This PR contains a few code cleanups/improvements. Please see the commits.

bluetech added 3 commits June 30, 2020 13:13
Just the nodeid is enough for the error messages.
This removes an import cycle.
A trylast is more appropriate for this usecase.

hookwrappers are more complicated and more expensive than regular
hookimpls, so better avoided.
This has been asserted like this since 04e9197
(i.e. 11 years, pytest 1.0), seems safe to simply remove at this point.
@RonnyPfannschmidt
Copy link
Member

I believe the intent for make item was to be truely last, for which it should use a tryfirst hookwrapper

Lovely changes, going to take a closer look at the computer later

@bluetech
Copy link
Member Author

bluetech commented Jul 2, 2020

I believe the intent for make item was to be truely last, for which it should use a tryfirst hookwrapper

Right, the hookwrapper would guarantee that this hookimpl would go after even another hook which uses trylast=True. But the question is why? We don't try to do it for other hooks. In fact, for firstresult hooks we usually provide a default impl without even trylast. The external plugins would normally win because they are registered after the builtin plugin. Or they could use tryfirst=True.

So maybe it shouldn't be trylast=True either..

@nicoddemus
Copy link
Member

nicoddemus commented Jul 3, 2020

So maybe it shouldn't be trylast=True either..

I'm guessing it might be because unittest's and python's pytest_pycollect_makeitem hooks might match the same object, but we want unittest to always take precedence regardless of the order of the plugins listed as builtin?

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.

Nice changes!

@bluetech
Copy link
Member Author

bluetech commented Jul 4, 2020

I'm guessing it might be because unittest's and python's pytest_pycollect_makeitem hooks might match the same object, but we want unittest to always take precedence regardless of the order of the plugins listed as builtin?

I think it's reasonable to rely on builtin plugins' registration order, but let's keep the trylast=True to be safe.

@bluetech bluetech merged commit eced536 into pytest-dev:master Jul 4, 2020
@nicoddemus
Copy link
Member

I think it's reasonable to rely on builtin plugins' registration order, but let's keep the trylast=True to be safe.

Agree on both accounts. 😁

@bluetech bluetech deleted the python-cleanups branch July 14, 2020 07:17
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.

3 participants