tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

conftest.py (3914B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 
      6 from ..fixtures import *  # noqa: F403
      7 
      8 
      9 def pytest_generate_tests(metafunc):
     10    """Generate tests based on markers."""
     11 
     12    if "session" not in metafunc.fixturenames:
     13        return
     14 
     15    marks = [mark.name for mark in metafunc.function.pytestmark]
     16 
     17    otherargs = {}
     18    argvalues = []
     19    ids = []
     20 
     21    if "only_firefox_versions" in marks:
     22        for mark in metafunc.function.pytestmark:
     23            if mark.name == "only_firefox_versions":
     24                otherargs["only_firefox_versions"] = mark.args
     25 
     26    if "only_platforms" in marks:
     27        for mark in metafunc.function.pytestmark:
     28            if mark.name == "only_platforms":
     29                otherargs["only_platforms"] = mark.args
     30 
     31    if "skip_platforms" in marks:
     32        for mark in metafunc.function.pytestmark:
     33            if mark.name == "skip_platforms":
     34                otherargs["skip_platforms"] = mark.args
     35 
     36    if "only_channels" in marks:
     37        for mark in metafunc.function.pytestmark:
     38            if mark.name == "only_channels":
     39                otherargs["only_channels"] = mark.args
     40 
     41    if "skip_channels" in marks:
     42        for mark in metafunc.function.pytestmark:
     43            if mark.name == "skip_channels":
     44                otherargs["skip_channels"] = mark.args
     45 
     46    if "need_visible_scrollbars" in marks:
     47        for mark in metafunc.function.pytestmark:
     48            if mark.name == "need_visible_scrollbars":
     49                otherargs["need_visible_scrollbars"] = mark.args
     50 
     51    if "actual_platform_required" in marks:
     52        otherargs["actual_platform_required"] = True
     53 
     54    if "no_overlay_scrollbars" in marks:
     55        otherargs["no_overlay_scrollbars"] = True
     56 
     57    if "enable_moztransform" in marks:
     58        otherargs["enable_moztransform"] = True
     59 
     60    if "disable_moztransform" in marks:
     61        otherargs["disable_moztransform"] = True
     62 
     63    if "enable_webkit_fill_available" in marks:
     64        otherargs["enable_webkit_fill_available"] = True
     65 
     66    if "disable_webkit_fill_available" in marks:
     67        otherargs["disable_webkit_fill_available"] = True
     68 
     69    if "with_interventions" in marks:
     70        argvalues.append([dict({"interventions": True}, **otherargs)])
     71        ids.append("with_interventions")
     72 
     73    if "without_interventions" in marks:
     74        argvalues.append([dict({"interventions": False}, **otherargs)])
     75        ids.append("without_interventions")
     76 
     77    metafunc.parametrize(["session"], argvalues, ids=ids, indirect=True)
     78 
     79 
     80 @pytest.fixture(scope="function")  # noqa: F405
     81 async def test_config(request, driver):
     82    params = request.node.callspec.params.get("session")
     83 
     84    use_interventions = params.get("interventions")
     85    print(f"use_interventions {use_interventions}")
     86    if use_interventions is None:
     87        raise ValueError(
     88            f"Missing intervention marker in {request.fspath}:{request.function.__name__}"
     89        )
     90 
     91    return {
     92        "actual_platform_required": params.get("actual_platform_required", False),
     93        "enable_moztransform": params.get("enable_moztransform", False),
     94        "enable_webkit_fill_available": params.get(
     95            "enable_webkit_fill_available", False
     96        ),
     97        "disable_moztransform": params.get("disable_moztransform", False),
     98        "disable_webkit_fill_available": params.get(
     99            "disable_webkit_fill_available", False
    100        ),
    101        "need_visible_scrollbars": params.get("need_visible_scrollbars", False),
    102        "no_overlay_scrollbars": params.get("no_overlay_scrollbars", False),
    103        "use_interventions": use_interventions,
    104        "use_pbm": params.get("with_private_browsing", False),
    105        "use_strict_etp": params.get("with_strict_etp", False),
    106        "without_tcp": params.get("without_tcp", False),
    107    }