Path: blob/trunk/py/test/selenium/webdriver/safari/safari_service_tests.py
1865 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617import os18from unittest.mock import patch1920import pytest2122from selenium.webdriver.safari.service import Service232425@pytest.fixture26def service():27return Service()282930@pytest.mark.usefixtures("service")31class TestSafariDriverService:32service_path = "/path/to/safaridriver"3334@pytest.fixture(autouse=True)35def setup_and_teardown(self):36os.environ["SE_SAFARIDRIVER"] = self.service_path37yield38os.environ.pop("SE_SAFARIDRIVER", None)3940def test_uses_path_from_env_variable(self, service):41assert "safaridriver" in service.path4243def test_updates_path_after_setting_env_variable(self, service):44service.executable_path = self.service_path # Simulating the update45with patch.dict("os.environ", {"SE_SAFARIDRIVER": "/foo/bar"}):46assert "safaridriver" in service.executable_path474849def test_enable_logging():50enable_logging = True51service = Service(enable_logging=enable_logging)52assert "--diagnose" in service.service_args535455def test_service_url():56service = Service(port=1313)57assert service.service_url == "http://localhost:1313"585960