Debian Codegraph @

test/selenium/webdriver/firefox/firefox_service_tests.py

raw symbols SCIP
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 import os
18 import subprocess
19
20 from selenium.webdriver import Firefox
21 from selenium.webdriver.firefox.service import Service
22
23
24 def test_log_output_as_filename() -> None:
25 log_file = "geckodriver.log"
26 service = Service(log_output=log_file)
27 try:
28 driver = Firefox(service=service)
29 with open(log_file) as fp:
30 assert "geckodriver\tINFO\tListening" in fp.readline()
31 finally:
32 driver.quit()
33 os.remove(log_file)
34
35
36 def test_log_output_as_file() -> None:
37 log_name = "geckodriver.log"
38 log_file = open(log_name, "w", encoding="utf-8")
39 service = Service(log_output=log_file)
40 try:
41 driver = Firefox(service=service)
42 with open(log_name) as fp:
43 assert "geckodriver\tINFO\tListening" in fp.readline()
44 finally:
45 driver.quit()
46 log_file.close()
47 os.remove(log_name)
48
49
50 def test_log_output_as_stdout(capfd) -> None:
51 service = Service(log_output=subprocess.STDOUT)
52 driver = Firefox(service=service)
53
54 out, err = capfd.readouterr()
55 assert "geckodriver\tINFO\tListening" in out
56 driver.quit()