Skip to content

Commit 765e6e9

Browse files
Skn0ttCopilot
andauthored
chore: require playwright>=1.60 in CI and unskip 1.60 tests (#313)
* chore: require playwright>=1.60 in CI and unskip 1.60 tests Playwright Python 1.60 has been released, so the tests gated on it can now run. Pin the dev dependency in local-requirements.txt so CI installs a compatible version; the package's runtime requirement is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test(connect_options): adapt to Playwright 1.59.1+ connect() API BrowserType.connect() renamed its first parameter from ws_endpoint to endpoint (positional) in microsoft/playwright-python#3050. The test also needs to look at stderr from the subprocess pytester run, since the WebSocket error log lands there. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: set PYTHONIOENCODING=utf-8 for pytester subprocesses Pytester decodes subprocess stdout as utf-8, but on Windows the default stdout encoding is cp1252. When Playwright's assertion failure messages contain non-ASCII characters (e.g. unicode arrows / multiplication signs), pytester raises UnicodeDecodeError. Force utf-8 in child Python processes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 703c884 commit 765e6e9

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

local-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ pre-commit==4.0.1
99
Django==4.2.24
1010
pytest-xdist==3.8.0
1111
pytest-asyncio==1.3.0
12+
playwright>=1.60

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ def pytest_configure(config: Any) -> None:
4141

4242
os.environ["PLAYWRIGHT_BROWSERS_PATH"] = playwright_browser_path
4343

44+
# Ensure subprocess pytester runs (and any child python processes) emit utf-8
45+
# on stdout/stderr so pytester's utf-8 decoding doesn't break on Windows.
46+
os.environ["PYTHONIOENCODING"] = "utf-8"
47+
4448

4549
class HTTPTestServer:
4650
PREFIX = ""

tests/test_asyncio.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,6 @@ def test_with_page(page):
10451045
]
10461046

10471047

1048-
@pytest.mark.skip(reason="requires 1.60")
10491048
def test_connect_options_should_work(testdir: pytest.Testdir) -> None:
10501049
server_process = None
10511050
try:
@@ -1056,7 +1055,7 @@ def test_connect_options_should_work(testdir: pytest.Testdir) -> None:
10561055
@pytest.fixture(scope="session")
10571056
def connect_options():
10581057
return {
1059-
"ws_endpoint": "ws://localhost:1234",
1058+
"endpoint": "ws://localhost:1234",
10601059
}
10611060
"""
10621061
)
@@ -1070,7 +1069,7 @@ async def test_connect_options(page):
10701069
"""
10711070
)
10721071
result = testdir.runpytest()
1073-
assert "connect ECONNREFUSED" in "".join(result.outlines)
1072+
assert "connect ECONNREFUSED" in "\n".join(result.outlines + result.errlines)
10741073
server_process = subprocess.Popen(
10751074
["playwright", "run-server", "--port=1234"],
10761075
stdout=subprocess.PIPE,
@@ -1111,7 +1110,6 @@ async def test_soft(page):
11111110
assert any("goodbye" in line for line in result.outlines)
11121111

11131112

1114-
@pytest.mark.skip(reason="requires 1.60")
11151113
def test_soft_assertion_multiple_failures_exception_group(
11161114
testdir: pytest.Testdir,
11171115
) -> None:
@@ -1133,7 +1131,6 @@ async def test_soft(page):
11331131
assert "first" in out and "second" in out
11341132

11351133

1136-
@pytest.mark.skip(reason="requires 1.60")
11371134
def test_soft_assertion_passes_when_all_match(testdir: pytest.Testdir) -> None:
11381135
testdir.makepyfile(
11391136
"""
@@ -1150,7 +1147,6 @@ async def test_soft(page):
11501147
result.assert_outcomes(passed=1)
11511148

11521149

1153-
@pytest.mark.skip(reason="requires 1.60")
11541150
def test_soft_assertion_does_not_shadow_body_failure(
11551151
testdir: pytest.Testdir,
11561152
) -> None:

tests/test_sync.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,6 @@ def test_with_page(page):
10351035
]
10361036

10371037

1038-
@pytest.mark.skip(reason="requires 1.60")
10391038
def test_connect_options_should_work(testdir: pytest.Testdir) -> None:
10401039
server_process = None
10411040
try:
@@ -1046,7 +1045,7 @@ def test_connect_options_should_work(testdir: pytest.Testdir) -> None:
10461045
@pytest.fixture(scope="session")
10471046
def connect_options():
10481047
return {
1049-
"ws_endpoint": "ws://localhost:1234",
1048+
"endpoint": "ws://localhost:1234",
10501049
}
10511050
"""
10521051
)
@@ -1057,7 +1056,7 @@ def test_connect_options(page):
10571056
"""
10581057
)
10591058
result = testdir.runpytest()
1060-
assert "connect ECONNREFUSED" in "".join(result.outlines)
1059+
assert "connect ECONNREFUSED" in "\n".join(result.outlines + result.errlines)
10611060
server_process = subprocess.Popen(
10621061
["playwright", "run-server", "--port=1234"],
10631062
stdout=subprocess.PIPE,
@@ -1095,7 +1094,6 @@ def test_soft(page):
10951094
assert any("goodbye" in line for line in result.outlines)
10961095

10971096

1098-
@pytest.mark.skip(reason="requires 1.60")
10991097
def test_soft_assertion_multiple_failures_exception_group(
11001098
testdir: pytest.Testdir,
11011099
) -> None:
@@ -1115,7 +1113,6 @@ def test_soft(page):
11151113
assert "first" in out and "second" in out
11161114

11171115

1118-
@pytest.mark.skip(reason="requires 1.60")
11191116
def test_soft_assertion_passes_when_all_match(testdir: pytest.Testdir) -> None:
11201117
testdir.makepyfile(
11211118
"""
@@ -1130,7 +1127,6 @@ def test_soft(page):
11301127
result.assert_outcomes(passed=1)
11311128

11321129

1133-
@pytest.mark.skip(reason="requires 1.60")
11341130
def test_soft_assertion_does_not_shadow_body_failure(
11351131
testdir: pytest.Testdir,
11361132
) -> None:

0 commit comments

Comments
 (0)