conftest.py (2713B)
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 import pytest 6 7 from unittest.mock import Mock, MagicMock 8 9 from marionette_driver.marionette import Marionette 10 11 from marionette_harness.runner.httpd import FixtureServer 12 13 14 @pytest.fixture(scope="module") 15 def logger(): 16 """ 17 Fake logger to help with mocking out other runner-related classes. 18 """ 19 import mozlog 20 21 return Mock(spec=mozlog.structuredlog.StructuredLogger) 22 23 24 @pytest.fixture 25 def mach_parsed_kwargs(logger): 26 """ 27 Parsed and verified dictionary used during simplest 28 call to mach marionette-test 29 """ 30 return { 31 "adb_path": None, 32 "addons": None, 33 "address": None, 34 "app": None, 35 "app_args": [], 36 "avd": None, 37 "avd_home": None, 38 "binary": "/path/to/firefox", 39 "browsermob_port": None, 40 "browsermob_script": None, 41 "device_serial": None, 42 "emulator": False, 43 "emulator_bin": None, 44 "gecko_log": None, 45 "jsdebugger": False, 46 "log_errorsummary": None, 47 "log_html": None, 48 "log_mach": None, 49 "log_mach_buffer": None, 50 "log_mach_level": None, 51 "log_mach_verbose": None, 52 "log_raw": None, 53 "log_raw_level": None, 54 "log_tbpl": None, 55 "log_tbpl_buffer": None, 56 "log_tbpl_compact": None, 57 "log_tbpl_level": None, 58 "log_unittest": None, 59 "log_xunit": None, 60 "logger_name": "Marionette-based Tests", 61 "prefs": {}, 62 "prefs_args": None, 63 "prefs_files": None, 64 "profile": None, 65 "pydebugger": None, 66 "repeat": None, 67 "run_until_failure": None, 68 "server_root": None, 69 "shuffle": False, 70 "shuffle_seed": 2276870381009474531, 71 "socket_timeout": 60.0, 72 "startup_timeout": 60, 73 "symbols_path": None, 74 "test_tags": None, 75 "tests": ["/path/to/unit-tests.toml"], 76 "testvars": None, 77 "this_chunk": None, 78 "timeout": None, 79 "total_chunks": None, 80 "verbose": None, 81 "workspace": None, 82 "logger": logger, 83 } 84 85 86 @pytest.fixture 87 def mock_httpd(request): 88 """Mock httpd instance""" 89 httpd = MagicMock(spec=FixtureServer) 90 return httpd 91 92 93 @pytest.fixture 94 def mock_marionette(request): 95 """Mock marionette instance""" 96 marionette = MagicMock(spec=dir(Marionette())) 97 if "has_crashed" in request.fixturenames: 98 marionette.check_for_crash.return_value = request.getfixturevalue("has_crashed") 99 return marionette