File tree Expand file tree Collapse file tree 3 files changed +43
-4
lines changed
Expand file tree Collapse file tree 3 files changed +43
-4
lines changed Original file line number Diff line number Diff line change 11[tool:pytest]
2- markers = skip_browser
2+ markers =
3+ skip_browser
4+ only_browser
35[mypy]
46ignore_missing_imports = True
Original file line number Diff line number Diff line change @@ -111,9 +111,21 @@ def is_chromium(browser_name):
111111
112112@pytest .fixture (autouse = True )
113113def skip_by_browser (request , browser_name ):
114- if request .node .get_closest_marker ("skip_browser" ):
115- if request .node .get_closest_marker ("skip_browser" ).args [0 ] == browser_name :
116- pytest .skip ("skipped on this platform: {}" .format (browser_name ))
114+ skip_browsers_names = []
115+
116+ # Allowlist
117+ only_browser_marker = request .node .get_closest_marker ("only_browser" )
118+ if only_browser_marker :
119+ skip_browsers_names = ["chromium" , "firefox" , "webkit" ]
120+ skip_browsers_names .remove (only_browser_marker .args [0 ])
121+
122+ # Denylist
123+ skip_browser_marker = request .node .get_closest_marker ("skip_browser" )
124+ if skip_browser_marker :
125+ skip_browsers_names .append (skip_browser_marker .args [0 ])
126+
127+ if browser_name in skip_browsers_names :
128+ pytest .skip ("skipped on this platform: {}" .format (browser_name ))
117129
118130
119131def pytest_addoption (parser ):
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 os
16+ import pytest
17+
18+ from playwright .page import Page
19+
20+
21+ @pytest .mark .only_browser ("chromium" )
22+ async def test_should_be_able_to_save_pdf_file (page : Page , server , tmpdir ):
23+ output_file = tmpdir / "foo.png"
24+ await page .pdf (path = str (output_file ))
25+ assert os .path .getsize (output_file ) > 0
You can’t perform that action at this time.
0 commit comments