Skip to content
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

Ensure Config.inifile is available during pytest_cmdline_main #9400

Merged
merged 2 commits into from Jan 4, 2022

Conversation

nicoddemus
Copy link
Member

Fix #9396

@@ -401,26 +401,10 @@ def Node_fspath_set(self: Node, value: LEGACY_PATH) -> None:


@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.

changelog/9396.bugfix.rst Outdated Show resolved Hide resolved
@@ -1264,15 +1264,16 @@ def pytest_load_initial_conftests(self):
m = My()
pm.register(m)
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