File tree Expand file tree Collapse file tree 5 files changed +48
-13
lines changed
Expand file tree Collapse file tree 5 files changed +48
-13
lines changed Original file line number Diff line number Diff line change 7979 run : python setup.py bdist_wheel
8080 - name : Install browsers
8181 run : python -m playwright install
82+ - name : Common Tests
83+ run : pytest -vv tests/common --browser=${{ matrix.browser }} --timeout 90
8284 - name : Test Sync API
8385 if : matrix.os != 'ubuntu-latest'
8486 run : pytest -vv tests/sync --browser=${{ matrix.browser }} --timeout 90
Original file line number Diff line number Diff line change 3737 docker exec --workdir /root/playwright/ "${CONTAINER_ID}" pip install -r local-requirements.txt
3838 docker exec --workdir /root/playwright/ "${CONTAINER_ID}" pip install -e .
3939 docker exec --workdir /root/playwright/ "${CONTAINER_ID}" python setup.py bdist_wheel
40+ docker exec --workdir /root/playwright/ "${CONTAINER_ID}" xvfb-run pytest -vv tests/common/
4041 docker exec --workdir /root/playwright/ "${CONTAINER_ID}" xvfb-run pytest -vv tests/sync/
4142 docker exec --workdir /root/playwright/ "${CONTAINER_ID}" xvfb-run pytest -vv tests/async/
Original file line number Diff line number Diff line change @@ -110,9 +110,15 @@ async def __aexit__(self, *args: Any) -> None:
110110 self ._connection .stop_async ()
111111
112112
113- if sys .platform == "win32" :
114- # Use ProactorEventLoop in 3.7, which is default in 3.8
115- asyncio .set_event_loop_policy (asyncio .WindowsProactorEventLoopPolicy ())
113+ if sys .version_info .major == 3 and sys .version_info .minor == 7 :
114+ if sys .platform == "win32" :
115+ # Use ProactorEventLoop in 3.7, which is default in 3.8
116+ asyncio .set_event_loop_policy (asyncio .WindowsProactorEventLoopPolicy ())
117+ else :
118+ # Prevent Python 3.7 from throwing on Linux:
119+ # RuntimeError: Cannot add child handler, the child watcher does not have a loop attached
120+ asyncio .get_event_loop ()
121+ asyncio .get_child_watcher ()
116122
117123
118124def main () -> None :
Original file line number Diff line number Diff line change @@ -6,16 +6,7 @@ markers =
66 only_platform
77junit_family =xunit2
88[mypy]
9- ignore_missing_imports = True
10- python_version = 3.7
11- warn_unused_ignores = False
12- warn_redundant_casts = True
13- warn_unused_configs = True
14- check_untyped_defs = True
15- disallow_untyped_defs = True
16- [mypy-tests.*]
17- check_untyped_defs = False
18- disallow_untyped_defs = False
9+ ignore_errors = True
1910[flake8]
2011ignore =
2112 E501
Original file line number Diff line number Diff line change 1+ # Copyright (c) Microsoft Corporation.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License")
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ import threading
16+
17+ from playwright import sync_playwright
18+
19+
20+ def test_running_in_thread (browser_name ):
21+ result = []
22+
23+ class TestThread (threading .Thread ):
24+ def run (self ):
25+ with sync_playwright () as playwright :
26+ browser = getattr (playwright , browser_name ).launch ()
27+ # This should not throw ^^.
28+ browser .newPage ()
29+ browser .close ()
30+ result .append ("Success" )
31+
32+ test_thread = TestThread ()
33+ test_thread .start ()
34+ test_thread .join ()
35+ assert "Success" in result
You can’t perform that action at this time.
0 commit comments