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

feat(gather): introduce sync gather for easier async tests migration #131

Merged
merged 1 commit into from
Aug 3, 2020

Conversation

pavelfeldman
Copy link
Member

No description provided.

@coveralls
Copy link

coveralls commented Aug 2, 2020

Pull Request Test Coverage Report for Build 192649967

  • 24 of 25 (96.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.07%) to 88.642%

Changes Missing Coverage Covered Lines Changed/Added Lines %
playwright/sync_base.py 24 25 96.0%
Files with Coverage Reduction New Missed Lines %
playwright/async_api.py 1 90.76%
Totals Coverage Status
Change from base Build 192377433: 0.07%
Covered Lines: 3395
Relevant Lines: 3830

💛 - Coveralls

Comment on lines 195 to 198
new_page._gather([
lambda: new_page.evaluate("() => new Promise(r => {})"),
lambda: new_page.close()
])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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()
)

@@ -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]:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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).

Copy link
Member Author

@pavelfeldman pavelfeldman Aug 3, 2020

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.

Copy link
Member Author

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.

@pavelfeldman pavelfeldman merged commit 87dceff into microsoft:master Aug 3, 2020
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.

3 participants