Skip to content

Conversation

nicoddemus
Copy link
Member

Fix #9396


@pytest.hookimpl
def pytest_configure(config: pytest.Config) -> None:
def pytest_load_initial_conftests(early_config: pytest.Config) -> None:
Copy link
Member Author

Choose a reason for hiding this comment

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

Changing to pytest_load_initial_conftests to monkey patch the attributes as it executes earlier than pytest_configure.

@pytest.hookimpl
def pytest_configure(config: pytest.Config) -> None:
"""Installs the LegacyTmpdirPlugin if the ``tmpdir`` plugin is also installed."""
if config.pluginmanager.has_plugin("tmpdir"):
Copy link
Member Author

Choose a reason for hiding this comment

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

The LegacyTmpdirPlugin should be installed during pytest_configure as that's called after tmpdir is installed.

hc = pm.hook.pytest_load_initial_conftests
values = hc._nonwrappers + hc._wrappers
expected = [
assert [x.function.__module__ for x in hc._nonwrappers] == [
Copy link
Member Author

Choose a reason for hiding this comment

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

Decided to also split checking wrappers and non-wrappers, seems better to explicitly test them separately.

@nicoddemus nicoddemus added the needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch label Dec 8, 2021
@nicoddemus
Copy link
Member Author

@RonnyPfannschmidt gentle ping. 👍

@The-Compiler
Copy link
Member

I've held back merging this as I wasn't sure if we preferred to revert the plugin entirely or not - with #9438 I assume we decided to keep it, but this conflicts now due to the import changes. After the conflicts are resolved I think this is good to go. Thanks @nicoddemus and happy new year! 🎉

@nicoddemus
Copy link
Member Author

I will fix this later today or tomorrow the latest! Happy new year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[prerelease] Attributes from legacypath plugin added too late?
4 participants