-
Notifications
You must be signed in to change notification settings - Fork 934
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
feat(gather): introduce sync gather for easier async tests migration #131
Conversation
Pull Request Test Coverage Report for Build 192649967
💛 - Coveralls |
tests/sync/test_sync.py
Outdated
new_page._gather([ | ||
lambda: new_page.evaluate("() => new Promise(r => {})"), | ||
lambda: new_page.close() | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new_page._gather([ | |
lambda: new_page.evaluate("() => new Promise(r => {})"), | |
lambda: new_page.close() | |
]) | |
new_page._gather( | |
lambda: new_page.evaluate("() => new Promise(r => {})"), | |
lambda: new_page.close() | |
) |
playwright/sync_base.py
Outdated
@@ -109,3 +110,34 @@ def once(self, event_name: str, handler: Any) -> None: | |||
|
|||
def remove_listener(self, event_name: str, handler: Any) -> None: | |||
self._impl_obj.remove_listener(event_name, handler) | |||
|
|||
def _gather(self, actions: List[Callable]) -> List[Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def _gather(self, actions: List[Callable]) -> List[Any]: | |
def _gather(self, *actions: List[Callable]) -> List[Any]: |
To align more with the default asyncio.gather I would not pass a list and more go like with the additional args approach (like arguments keyword in JS). (If it does not work, try renaming *actions to *args).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started like that, but then I chose to make it return array of values and input array felt more natural.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started like that, but then I chose to make it return array of values and imput array felt more natural.
Having said that, if we manage to generate tests - happy to do it that way.
066d988
to
3f72ec1
Compare
3f72ec1
to
8090882
Compare
No description provided.