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: lint examples and fix to_{have,contain}_text with lists #1675

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ repos:
hooks:
- id: mypy
additional_dependencies: [types-pyOpenSSL==22.1.0.1]
exclude: examples/
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ def assert_number_of_todos_in_local_storage(page: Page, expected: int) -> None:


def check_todos_in_local_storage(page: Page, title: str) -> None:
title in page.evaluate("JSON.parse(localStorage['react-todos']).map(i => i.title)")
assert title in page.evaluate(
"JSON.parse(localStorage['react-todos']).map(i => i.title)"
)
52 changes: 44 additions & 8 deletions playwright/_impl/_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ def _not(self) -> "LocatorAssertions":

async def to_contain_text(
self,
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
expected: Union[
List[str],
List[Pattern[str]],
List[Union[Pattern[str], str]],
Pattern[str],
str,
],
use_inner_text: bool = None,
timeout: float = None,
ignore_case: bool = None,
Expand Down Expand Up @@ -163,7 +169,13 @@ async def to_contain_text(

async def not_to_contain_text(
self,
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
expected: Union[
List[str],
List[Pattern[str]],
List[Union[Pattern[str], str]],
Pattern[str],
str,
],
use_inner_text: bool = None,
timeout: float = None,
ignore_case: bool = None,
Expand Down Expand Up @@ -199,7 +211,13 @@ async def not_to_have_attribute(

async def to_have_class(
self,
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
expected: Union[
List[str],
List[Pattern[str]],
List[Union[Pattern[str], str]],
Pattern[str],
str,
],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand All @@ -222,7 +240,13 @@ async def to_have_class(

async def not_to_have_class(
self,
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
expected: Union[
List[str],
List[Pattern[str]],
List[Union[Pattern[str], str]],
Pattern[str],
str,
],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand Down Expand Up @@ -346,7 +370,7 @@ async def not_to_have_value(

async def to_have_values(
self,
values: List[Union[Pattern[str], str]],
values: Union[List[str], List[Pattern[str]], List[Union[Pattern[str], str]]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
Expand All @@ -360,15 +384,21 @@ async def to_have_values(

async def not_to_have_values(
self,
values: List[Union[Pattern[str], str]],
values: Union[List[str], List[Pattern[str]], List[Union[Pattern[str], str]]],
timeout: float = None,
) -> None:
__tracebackhide__ = True
await self._not.to_have_values(values, timeout)

async def to_have_text(
self,
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
expected: Union[
List[str],
List[Pattern[str]],
List[Union[Pattern[str], str]],
Pattern[str],
str,
],
use_inner_text: bool = None,
timeout: float = None,
ignore_case: bool = None,
Expand Down Expand Up @@ -407,7 +437,13 @@ async def to_have_text(

async def not_to_have_text(
self,
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
expected: Union[
List[str],
List[Pattern[str]],
List[Union[Pattern[str], str]],
Pattern[str],
str,
],
use_inner_text: bool = None,
timeout: float = None,
ignore_case: bool = None,
Expand Down
40 changes: 30 additions & 10 deletions playwright/async_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -16395,6 +16395,8 @@ class LocatorAssertions(AsyncBase):
async def to_contain_text(
self,
expected: typing.Union[
typing.List[str],
typing.List[typing.Pattern[str]],
typing.List[typing.Union[typing.Pattern[str], str]],
typing.Pattern[str],
str,
Expand Down Expand Up @@ -16454,7 +16456,7 @@ async def to_contain_text(

Parameters
----------
expected : Union[List[Union[Pattern[str], str]], Pattern[str], str]
expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str]
Expected substring or RegExp or a list of those.
use_inner_text : Union[bool, None]
Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text.
Expand All @@ -16478,6 +16480,8 @@ async def to_contain_text(
async def not_to_contain_text(
self,
expected: typing.Union[
typing.List[str],
typing.List[typing.Pattern[str]],
typing.List[typing.Union[typing.Pattern[str], str]],
typing.Pattern[str],
str,
Expand All @@ -16493,7 +16497,7 @@ async def not_to_contain_text(

Parameters
----------
expected : Union[List[Union[Pattern[str], str]], Pattern[str], str]
expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str]
Expected substring or RegExp or a list of those.
use_inner_text : Union[bool, None]
Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text.
Expand Down Expand Up @@ -16580,6 +16584,8 @@ async def not_to_have_attribute(
async def to_have_class(
self,
expected: typing.Union[
typing.List[str],
typing.List[typing.Pattern[str]],
typing.List[typing.Union[typing.Pattern[str], str]],
typing.Pattern[str],
str,
Expand Down Expand Up @@ -16615,7 +16621,7 @@ async def to_have_class(

Parameters
----------
expected : Union[List[Union[Pattern[str], str]], Pattern[str], str]
expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str]
Expected class or RegExp or a list of those.
timeout : Union[float, None]
Time to retry the assertion for.
Expand All @@ -16631,6 +16637,8 @@ async def to_have_class(
async def not_to_have_class(
self,
expected: typing.Union[
typing.List[str],
typing.List[typing.Pattern[str]],
typing.List[typing.Union[typing.Pattern[str], str]],
typing.Pattern[str],
str,
Expand All @@ -16644,7 +16652,7 @@ async def not_to_have_class(

Parameters
----------
expected : Union[List[Union[Pattern[str], str]], Pattern[str], str]
expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str]
Expected class or RegExp or a list of those.
timeout : Union[float, None]
Time to retry the assertion for.
Expand Down Expand Up @@ -16931,7 +16939,11 @@ async def not_to_have_value(

async def to_have_values(
self,
values: typing.List[typing.Union[typing.Pattern[str], str]],
values: typing.Union[
typing.List[str],
typing.List[typing.Pattern[str]],
typing.List[typing.Union[typing.Pattern[str], str]],
],
*,
timeout: typing.Optional[float] = None
) -> None:
Expand Down Expand Up @@ -16961,7 +16973,7 @@ async def to_have_values(

Parameters
----------
values : List[Union[Pattern[str], str]]
values : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str]]
Expected options currently selected.
timeout : Union[float, None]
Time to retry the assertion for.
Expand All @@ -16976,7 +16988,11 @@ async def to_have_values(

async def not_to_have_values(
self,
values: typing.List[typing.Union[typing.Pattern[str], str]],
values: typing.Union[
typing.List[str],
typing.List[typing.Pattern[str]],
typing.List[typing.Union[typing.Pattern[str], str]],
],
*,
timeout: typing.Optional[float] = None
) -> None:
Expand All @@ -16986,7 +17002,7 @@ async def not_to_have_values(

Parameters
----------
values : List[Union[Pattern[str], str]]
values : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str]]
Expected options currently selected.
timeout : Union[float, None]
Time to retry the assertion for.
Expand All @@ -17002,6 +17018,8 @@ async def not_to_have_values(
async def to_have_text(
self,
expected: typing.Union[
typing.List[str],
typing.List[typing.Pattern[str]],
typing.List[typing.Union[typing.Pattern[str], str]],
typing.Pattern[str],
str,
Expand Down Expand Up @@ -17059,7 +17077,7 @@ async def to_have_text(

Parameters
----------
expected : Union[List[Union[Pattern[str], str]], Pattern[str], str]
expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str]
Expected substring or RegExp or a list of those.
use_inner_text : Union[bool, None]
Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text.
Expand All @@ -17083,6 +17101,8 @@ async def to_have_text(
async def not_to_have_text(
self,
expected: typing.Union[
typing.List[str],
typing.List[typing.Pattern[str]],
typing.List[typing.Union[typing.Pattern[str], str]],
typing.Pattern[str],
str,
Expand All @@ -17098,7 +17118,7 @@ async def not_to_have_text(

Parameters
----------
expected : Union[List[Union[Pattern[str], str]], Pattern[str], str]
expected : Union[List[Pattern[str]], List[Union[Pattern[str], str]], List[str], Pattern[str], str]
Expected substring or RegExp or a list of those.
use_inner_text : Union[bool, None]
Whether to use `element.innerText` instead of `element.textContent` when retrieving DOM node text.
Expand Down