# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import errno import os import shutil import tempfile
args = [ "--strict", # turn warnings into errors "-vv", # show each individual subtest and full failure logs "--capture", "no", # enable stdout/stderr from tests "--basetemp",
cache, # temporary directory "--showlocals", # display contents of variables in local scope "-p", "no:mozlog", # use the WPT result recorder "--disable-warnings", "-rfEs", "-p", "no:cacheprovider", # disable state preservation across invocations "-o=console_output_style=classic", # disable test progress bar "--browser", "firefox", "--webdriver-binary",
webdriver_binary, "--webdriver-port",
webdriver_port, "--webdriver-ws-port",
webdriver_ws_port, "--webdriver-log-level",
log_level,
]
if debug:
args.append("--pdb")
if headless:
args.append("--headless")
if browser_binary:
args.append("--browser-binary")
args.append(browser_binary)
if device_serial:
args.append("--device-serial")
args.append(device_serial)
if package_name:
args.append("--package-name")
args.append(package_name)
if addon:
args.append("--addon")
args.append(addon)
if do2fa:
args.append("--do2fa")
if config:
args.append("--config")
args.append(config)
if failure_screenshots_dir:
args.append("--failure-screenshots-dir")
args.append(failure_screenshots_dir)
if no_failure_screenshots:
args.append("--no-failure-screenshots")
if interventions isnotNoneand shims isnotNone: raise ValueError( "Must provide only one of interventions or shims argument"
) elif interventions isNoneand shims isNone: raise ValueError( "Must provide either an interventions or shims argument"
)
name = "webcompat-interventions" if interventions == "enabled":
args.extend(["-m", "with_interventions"]) elif interventions == "disabled":
args.extend(["-m", "without_interventions"]) elif interventions isnotNone: raise ValueError(f"Invalid value for interventions {interventions}") if shims == "enabled":
args.extend(["-m", "with_shims"])
name = "smartblock-shims" elif shims == "disabled":
args.extend(["-m", "without_shims"])
name = "smartblock-shims" elif shims isnotNone: raise ValueError(f"Invalid value for shims {shims}") else:
name = "smartblock-shims"
if bugs isnotNone:
args.extend(["-k", " or ".join(bugs)])
class WDConfig: def pytest_addoption(self, parser):
parser.addoption( "--browser-binary", action="store", help="Path to browser binary"
)
parser.addoption( "--webdriver-binary", action="store", help="Path to webdriver binary"
)
parser.addoption( "--webdriver-port",
action="store",
default="4444",
help="Port on which to run WebDriver",
)
parser.addoption( "--webdriver-ws-port",
action="store",
default="9222",
help="Port on which to run WebDriver BiDi websocket",
)
parser.addoption( "--webdriver-log-level",
action="store",
default="INFO",
help="Log level to use for WebDriver",
)
parser.addoption( "--browser", action="store", choices=["firefox"], help="Name of the browser"
)
parser.addoption( "--do2fa",
action="store_true",
default=False,
help="Do two-factor auth live in supporting tests",
)
parser.addoption( "--failure-screenshots-dir",
action="store",
help="Path to save failure screenshots",
)
parser.addoption( "--no-failure-screenshots",
action="store_true",
default=False,
help="Do not save screenshots on failure",
)
parser.addoption( "--config",
action="store",
help="Path to JSON file containing logins and other settings",
)
parser.addoption( "--addon",
action="store",
help="Path to the webcompat addon XPI to use",
)
parser.addoption( "--device-serial",
action="store",
help="Emulator device serial number",
)
parser.addoption( "--package-name",
action="store",
default=GVE,
help="Android package to run/connect to",
)
parser.addoption( "--headless", action="store_true", help="Run browser in headless mode"
)
class ResultRecorder(object): def __init__(self, logger):
self.logger = logger
def pytest_runtest_logreport(self, report): if report.passed and report.when == "call":
self.record_pass(report) elif report.failed: if report.when != "call":
self.record_error(report) else:
self.record_fail(report) elif report.skipped:
self.record_skip(report)
def record_fail(self, report): # pytest outputs the stacktrace followed by an error message prefixed # with "E ", e.g. # # def test_example(): # > assert "fuu" in "foobar" # > E AssertionError: assert 'fuu' in 'foobar'
message = "" for line in report.longreprtext.splitlines(): if line.startswith("E "):
message = line[1:].strip() break
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.