Skip to content

Conversation

@JamesYFC
Copy link
Contributor

Currently, the plugins check for the full names of the other plugin (pytest_playwright.pytest_playwright in async, and pytest_playwright_asyncio.pytest_playwright in sync) against the PytestPluginManager's name-to-plugin dict, in order to error if the other, incompatible, plugin has been loaded.

However, in my project (and it seems like this is pretty common), plugins will be registered under the "common" name:

image

And so this will fail to raise the error, and we will get this one instead which is much less helpful:

image

This PR does an additional check for the "common" name, and then checks that the plugin itself has the matching canonical name, which should now handle this case.

As far as I can see, I couldn't find a decent way to register a plugin under a different name as part of the pytest invocation, and so I haven't added the additional test case.

In the given example above though, this now gives us the expected error:
image

@JamesYFC
Copy link
Contributor Author

@microsoft-github-policy-service agree [company="{your company}"]

@microsoft-github-policy-service agree [company="JamesYFC"]

@JamesYFC
Copy link
Contributor Author

@microsoft-github-policy-service agree

Copy link

@dgozman dgozman left a comment

Choose a reason for hiding this comment

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

Thank you for the PR, this is fantastic!

I am very sorry that this PR slipped through our triage process, and nobody looked at it. I've only got a minor comment, and would totally understand if you don't have cycles to update this PR anymore.

In any case, thank you for contributing!

# Check for incompatible async plugin with canonical name
if pluginmanager.has_plugin(PW_ASYNC_CANONICAL_NAME):
raise RuntimeError(
"pytest-playwright and pytest-playwright-asyncio are not compatible. Please use only one of them."
Copy link

Choose a reason for hiding this comment

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

nit: use PLUGIN_INCOMPATIBLE_MESSAGE here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@JamesYFC JamesYFC force-pushed the fix/plugin-incompat branch from a61b1fd to a84cedf Compare November 13, 2025 23:03
@JamesYFC
Copy link
Contributor Author

Thanks for the kind reply. I've amended my commit for your viewing pleasure :)

Copy link

@dgozman dgozman left a comment

Choose a reason for hiding this comment

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

Looks great, merging in.

@dgozman dgozman merged commit 1d64430 into microsoft:main Nov 14, 2025
15 checks passed
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.

2 participants