Skip to content

Commit eaf3f15

Browse files
authored
chore: lint examples and fix to_{have,contain}_text with lists (microsoft#1675)
1 parent d87e105 commit eaf3f15

21 files changed

+7389
-4128
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ repos:
2323
hooks:
2424
- id: mypy
2525
additional_dependencies: [types-pyOpenSSL==22.1.0.1]
26-
exclude: examples/
2726
- repo: https://github.com/pycqa/flake8
2827
rev: 5.0.4
2928
hooks:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Playwright is a Python library to automate [Chromium](https://www.chromium.org/H
44

55
| | Linux | macOS | Windows |
66
| :--- | :---: | :---: | :---: |
7-
| Chromium <!-- GEN:chromium-version -->108.0.5359.29<!-- GEN:stop --> ||||
7+
| Chromium <!-- GEN:chromium-version -->108.0.5359.48<!-- GEN:stop --> ||||
88
| WebKit <!-- GEN:webkit-version -->16.4<!-- GEN:stop --> ||||
99
| Firefox <!-- GEN:firefox-version -->106.0<!-- GEN:stop --> ||||
1010

examples/todomvc/tests/utils.py renamed to examples/todomvc/mvctests/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ def assert_number_of_todos_in_local_storage(page: Page, expected: int) -> None:
2323

2424

2525
def check_todos_in_local_storage(page: Page, title: str) -> None:
26-
title in page.evaluate("JSON.parse(localStorage['react-todos']).map(i => i.title)")
26+
assert title in page.evaluate(
27+
"JSON.parse(localStorage['react-todos']).map(i => i.title)"
28+
)

playwright/_impl/_assertions.py

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ def _not(self) -> "LocatorAssertions":
120120

121121
async def to_contain_text(
122122
self,
123-
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
123+
expected: Union[
124+
List[str],
125+
List[Pattern[str]],
126+
List[Union[Pattern[str], str]],
127+
Pattern[str],
128+
str,
129+
],
124130
use_inner_text: bool = None,
125131
timeout: float = None,
126132
ignore_case: bool = None,
@@ -163,7 +169,13 @@ async def to_contain_text(
163169

164170
async def not_to_contain_text(
165171
self,
166-
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
172+
expected: Union[
173+
List[str],
174+
List[Pattern[str]],
175+
List[Union[Pattern[str], str]],
176+
Pattern[str],
177+
str,
178+
],
167179
use_inner_text: bool = None,
168180
timeout: float = None,
169181
ignore_case: bool = None,
@@ -199,7 +211,13 @@ async def not_to_have_attribute(
199211

200212
async def to_have_class(
201213
self,
202-
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
214+
expected: Union[
215+
List[str],
216+
List[Pattern[str]],
217+
List[Union[Pattern[str], str]],
218+
Pattern[str],
219+
str,
220+
],
203221
timeout: float = None,
204222
) -> None:
205223
__tracebackhide__ = True
@@ -222,7 +240,13 @@ async def to_have_class(
222240

223241
async def not_to_have_class(
224242
self,
225-
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
243+
expected: Union[
244+
List[str],
245+
List[Pattern[str]],
246+
List[Union[Pattern[str], str]],
247+
Pattern[str],
248+
str,
249+
],
226250
timeout: float = None,
227251
) -> None:
228252
__tracebackhide__ = True
@@ -346,7 +370,7 @@ async def not_to_have_value(
346370

347371
async def to_have_values(
348372
self,
349-
values: List[Union[Pattern[str], str]],
373+
values: Union[List[str], List[Pattern[str]], List[Union[Pattern[str], str]]],
350374
timeout: float = None,
351375
) -> None:
352376
__tracebackhide__ = True
@@ -360,15 +384,21 @@ async def to_have_values(
360384

361385
async def not_to_have_values(
362386
self,
363-
values: List[Union[Pattern[str], str]],
387+
values: Union[List[str], List[Pattern[str]], List[Union[Pattern[str], str]]],
364388
timeout: float = None,
365389
) -> None:
366390
__tracebackhide__ = True
367391
await self._not.to_have_values(values, timeout)
368392

369393
async def to_have_text(
370394
self,
371-
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
395+
expected: Union[
396+
List[str],
397+
List[Pattern[str]],
398+
List[Union[Pattern[str], str]],
399+
Pattern[str],
400+
str,
401+
],
372402
use_inner_text: bool = None,
373403
timeout: float = None,
374404
ignore_case: bool = None,
@@ -407,7 +437,13 @@ async def to_have_text(
407437

408438
async def not_to_have_text(
409439
self,
410-
expected: Union[List[Union[Pattern[str], str]], Pattern[str], str],
440+
expected: Union[
441+
List[str],
442+
List[Pattern[str]],
443+
List[Union[Pattern[str], str]],
444+
Pattern[str],
445+
str,
446+
],
411447
use_inner_text: bool = None,
412448
timeout: float = None,
413449
ignore_case: bool = None,

0 commit comments

Comments
 (0)