From bad3c8b1b503a87dbdf8b9e919993bf365ceacca Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 27 Jan 2025 07:57:02 +0100 Subject: [PATCH] fix(assertions): allow tuple as valid input type for expected text values --- playwright/_impl/_assertions.py | 2 +- tests/async/test_assertions.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/playwright/_impl/_assertions.py b/playwright/_impl/_assertions.py index fce405da7..b226e241f 100644 --- a/playwright/_impl/_assertions.py +++ b/playwright/_impl/_assertions.py @@ -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( diff --git a/tests/async/test_assertions.py b/tests/async/test_assertions.py index 88b9c1b4f..dc0a1e615 100644 --- a/tests/async/test_assertions.py +++ b/tests/async/test_assertions.py @@ -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(