Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/test/selenium/webdriver/safari/safari_service_tests.py
1865 views
1
# Licensed to the Software Freedom Conservancy (SFC) under one
2
# or more contributor license agreements. See the NOTICE file
3
# distributed with this work for additional information
4
# regarding copyright ownership. The SFC licenses this file
5
# to you under the Apache License, Version 2.0 (the
6
# "License"); you may not use this file except in compliance
7
# with the License. You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing,
12
# software distributed under the License is distributed on an
13
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
# KIND, either express or implied. See the License for the
15
# specific language governing permissions and limitations
16
# under the License.
17
18
import os
19
from unittest.mock import patch
20
21
import pytest
22
23
from selenium.webdriver.safari.service import Service
24
25
26
@pytest.fixture
27
def service():
28
return Service()
29
30
31
@pytest.mark.usefixtures("service")
32
class TestSafariDriverService:
33
service_path = "/path/to/safaridriver"
34
35
@pytest.fixture(autouse=True)
36
def setup_and_teardown(self):
37
os.environ["SE_SAFARIDRIVER"] = self.service_path
38
yield
39
os.environ.pop("SE_SAFARIDRIVER", None)
40
41
def test_uses_path_from_env_variable(self, service):
42
assert "safaridriver" in service.path
43
44
def test_updates_path_after_setting_env_variable(self, service):
45
service.executable_path = self.service_path # Simulating the update
46
with patch.dict("os.environ", {"SE_SAFARIDRIVER": "/foo/bar"}):
47
assert "safaridriver" in service.executable_path
48
49
50
def test_enable_logging():
51
enable_logging = True
52
service = Service(enable_logging=enable_logging)
53
assert "--diagnose" in service.service_args
54
55
56
def test_service_url():
57
service = Service(port=1313)
58
assert service.service_url == "http://localhost:1313"
59
60