Skip to content

Commit

Permalink
fix(assertions): allow tuple as valid input type for expected text va…
Browse files Browse the repository at this point in the history
…lues (#2723)
  • Loading branch information
mxschmitt authored Jan 27, 2025
1 parent 9010889 commit 4ecf61e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion playwright/_impl/_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ def to_expected_text_values(
ignoreCase: Optional[bool] = None,
) -> Sequence[ExpectedTextValue]:
out: List[ExpectedTextValue] = []
assert isinstance(items, list)
assert isinstance(items, (list, tuple))
for item in items:
if isinstance(item, str):
o = ExpectedTextValue(
Expand Down
4 changes: 4 additions & 0 deletions tests/async/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ async def test_assertions_locator_to_have_text(page: Page, server: Server) -> No
await expect(page.locator("div")).to_have_text(
["Text 1", re.compile(r"Text \d+a")]
)
# Should work with a tuple
await expect(page.locator("div")).to_have_text(
("Text 1", re.compile(r"Text \d+a"))
)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 4ecf61e

Please sign in to comment.