Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[tool:pytest]
markers = skip_browser
markers =
skip_browser
only_browser
[mypy]
ignore_missing_imports = True
18 changes: 15 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,21 @@ def is_chromium(browser_name):

@pytest.fixture(autouse=True)
def skip_by_browser(request, browser_name):
if request.node.get_closest_marker("skip_browser"):
if request.node.get_closest_marker("skip_browser").args[0] == browser_name:
pytest.skip("skipped on this platform: {}".format(browser_name))
skip_browsers_names = []

# Allowlist
only_browser_marker = request.node.get_closest_marker("only_browser")
if only_browser_marker:
skip_browsers_names = ["chromium", "firefox", "webkit"]
skip_browsers_names.remove(only_browser_marker.args[0])

# Denylist
skip_browser_marker = request.node.get_closest_marker("skip_browser")
if skip_browser_marker:
skip_browsers_names.append(skip_browser_marker.args[0])

if browser_name in skip_browsers_names:
pytest.skip("skipped on this platform: {}".format(browser_name))


def pytest_addoption(parser):
Expand Down
25 changes: 25 additions & 0 deletions tests/test_pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) Microsoft Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import pytest

from playwright.page import Page


@pytest.mark.only_browser("chromium")
async def test_should_be_able_to_save_pdf_file(page: Page, server, tmpdir):
output_file = tmpdir / "foo.png"
await page.pdf(path=str(output_file))
assert os.path.getsize(output_file) > 0