Skip to content

add --disable-plugin-autoload #13253

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 9 commits into from
Mar 1, 2025

Conversation

jakkdl
Copy link
Member

@jakkdl jakkdl commented Feb 25, 2025

fixes #8969

I'm pretty sure the implementation is solid, but I have a bunch of question marks in comments that should be resolved before merging. I can probably resolve them on my own by digging deep enough into the innards, but wouldn't mind explanations if somebody is more familiar with that territory.

I'm not entirely sure that test_installed_plugin_rewrite should be parametrized to hell, as opposed to creating a dedicated test.

I also found a random unrelated typo in test_installed_plugin_rewrite with check_first -> check_first2, so fixed that + improved the fnmatch_lines.

  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits. Please uncheck this if you prefer to squash the commits yourself.
  • Create a new changelog file in the changelog folder, with a name like <ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.

@jakkdl jakkdl requested a review from Zac-HD February 25, 2025 16:45
@Zac-HD
Copy link
Member

Zac-HD commented Feb 26, 2025

I don't have answers for those questions, sorry, but I'm happy to say that the PR is looking good overall, and I'm looking forward to merging it once they're resolved and CI is green 🙂

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Feb 27, 2025
@jakkdl
Copy link
Member Author

jakkdl commented Feb 27, 2025

I can't repro the pypy fail locally, but I'm not sure if spec matters, so ??

I've updated comments to something that almost makes sense to merge with, but ... it's a mess.

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

This looks good to me, but I'd appreciate a second opinion before merging. Maybe @nicoddemus?

@nicoddemus
Copy link
Member

This looks good to me, but I'd appreciate a second opinion before merging. Maybe @nicoddemus?

Will do, likely tomorrow! 👍

Copy link
Member

@The-Compiler The-Compiler left a comment

Choose a reason for hiding this comment

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

Can't say much about all the things that are going on in the tests, just a few nitpicks I noticed while looking through the diff.

if mode == "plain":
expected = "E AssertionError"
elif mode == "rewrite":
expected = "*assert 10 == 30*"
else:
assert 0
result.stdout.fnmatch_lines([expected])

if not disable_plugin_autoload or explicit_specify:
Copy link
Member

Choose a reason for hiding this comment

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

With all the additional logic in this test, I wonder if it would be better to have a fixture for the hampkg and split this into two distinct tests at least (autoload enabled/disabled)?

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.

Thanks @jakkdl for the PR, appreciate it!

# FIXME: if it's already loaded then you get a ValueError: "Plugin already
# registered under a different name."
# vaguely related to https://github.com/pytest-dev/pytest/issues/5661
name = "spamplugin" if disable_plugin_autoload else "spam"
Copy link
Member

Choose a reason for hiding this comment

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

The difference here is that when loading via entry point, the plugin can choose its own name (name = 'spam'), but when loading via other methods the name of the module is used (spamplugin).

I have simplified things here by always using spamplugin as the name of the plugin (b157cef).

@Zac-HD Zac-HD merged commit 5bd393c into pytest-dev:main Mar 1, 2025
28 checks passed
@jakkdl jakkdl deleted the disable_plugin_autoload_cli branch March 3, 2025 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable plugin autoload via configuration file
4 participants