File tree 5 files changed +48
-13
lines changed 5 files changed +48
-13
lines changed Original file line number Diff line number Diff line change 79
79
run : python setup.py bdist_wheel
80
80
- name : Install browsers
81
81
run : python -m playwright install
82
+ - name : Common Tests
83
+ run : pytest -vv tests/common --browser=${{ matrix.browser }} --timeout 90
82
84
- name : Test Sync API
83
85
if : matrix.os != 'ubuntu-latest'
84
86
run : pytest -vv tests/sync --browser=${{ matrix.browser }} --timeout 90
Original file line number Diff line number Diff line change 37
37
docker exec --workdir /root/playwright/ "${CONTAINER_ID}" pip install -r local-requirements.txt
38
38
docker exec --workdir /root/playwright/ "${CONTAINER_ID}" pip install -e .
39
39
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/
40
41
docker exec --workdir /root/playwright/ "${CONTAINER_ID}" xvfb-run pytest -vv tests/sync/
41
42
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:
110
110
self ._connection .stop_async ()
111
111
112
112
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 ()
116
122
117
123
118
124
def main () -> None :
Original file line number Diff line number Diff line change @@ -6,16 +6,7 @@ markers =
6
6
only_platform
7
7
junit_family =xunit2
8
8
[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
19
10
[flake8]
20
11
ignore =
21
12
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