Do some refactoring

This commit is contained in:
Michael Mintz 2023-12-07 22:50:55 -05:00
parent fc684c3698
commit 001088b5f0
2 changed files with 11 additions and 21 deletions

View File

@ -27,7 +27,11 @@ def create_proxy_ext(
if not bypass_list:
bypass_list = ""
if proxy_string:
proxy_host = proxy_string.split(":")[0]
proxy_protocol = ""
if proxy_string.count("://") == 1:
proxy_protocol = proxy_string.split("://")[0] + "://"
proxy_string = proxy_string.split("://")[1]
proxy_host = proxy_protocol + proxy_string.split(":")[0]
proxy_port = proxy_string.split(":")[1]
background_js = (
"""var config = {\n"""

View File

@ -199,22 +199,17 @@ class BaseCase(unittest.TestCase):
Eg. "python my_test.py" instead of "pytest my_test.py"."""
if name == "__main__": # Test called with "python"
import subprocess
from pytest import main as pytest_main
all_args = []
for arg in args:
all_args.append(arg)
for arg in sys.argv[1:]:
all_args.append(arg)
multi = False
for arg in all_args:
if arg.startswith("-n") or arg.startswith("--numprocesses"):
multi = True
if multi:
subprocess.call(
[sys.executable, "-m", "pytest", file, "-s", *all_args]
)
else:
pytest_main([file, "-s", *all_args])
# See: https://stackoverflow.com/a/54666289/7058266
# from pytest import main as pytest_main
# pytest_main([file, "-s", *all_args])
subprocess.call(
[sys.executable, "-m", "pytest", file, "-s", *all_args]
)
def open(self, url):
"""Navigates the current browser window to the specified page."""
@ -13586,15 +13581,6 @@ class BaseCase(unittest.TestCase):
############
@decorators.deprecated("The Driver Manager prevents old drivers.")
def is_chromedriver_too_old(self):
"""Before chromedriver 73, there was no version check, which
means it's possible to run a new Chrome with old drivers."""
self.__fail_if_not_using_chrome("is_chromedriver_too_old()")
if int(self.get_chromedriver_version().split(".")[0]) < 73:
return True # chromedriver is too old! Please upgrade!
return False
@decorators.deprecated("You should use re.escape() instead.")
def jq_format(self, code):
# DEPRECATED - re.escape() already performs this action.