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

chore: introduce asyncio mode #184

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

chore: introduce asyncio mode #184

wants to merge 3 commits into from

Conversation

mxschmitt
Copy link
Member

@mxschmitt mxschmitt commented Sep 1, 2023

This uses async fixtures if the pytest-asyncio plugin is loaded, we might should harden this condition more, since there might be projects where the pytest-asyncio plugin is loaded but the users wants sync fixtures.

Also all the tests got mirrored, changed to the asyncio way of doing this except two UnitTest tests, which are not supported with pytest-asyncio see here.

Ref: https://docs.pytest.org/en/7.1.x/how-to/writing_hook_functions.html#optionally-using-hooks-from-3rd-party-plugins
#74


Edit: Ideally we can have sync/async on a folder level.

@mxschmitt
Copy link
Member Author

Just a recap of this issue and why we don't proceed:

Ideally we can have sync and async in the same repository and based on if a test file is marked as sync, it uses the sync fixtures or its async and it uses the async Playwright fixtures.

So far I didn't find a great way of doing that Pytest wise.

@mxschmitt mxschmitt mentioned this pull request Jan 25, 2024
Copy link

@jamesbraza jamesbraza left a comment

Choose a reason for hiding this comment

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



def pytest_configure(config: pytest.Config) -> None:
if (config.getini("playwright_pytest_asyncio") is None and config.pluginmanager.hasplugin("asyncio")) or config.getini("playwright_pytest_asyncio"):

Choose a reason for hiding this comment

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

To share, I have seen others using AnyIO for async testing: https://anyio.readthedocs.io/en/1.4.0/testing.html

It might be good to account for other async plugins that can trigger registration of PytestPlaywrightAsyncio

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