Skip to content

Commit e28f37b

Browse files
committed
Update code related to deprecated methods
1 parent f6737bc commit e28f37b

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

seleniumbase/common/decorators.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import inspect
21
import logging
32
import math
43
import sys
5-
import threading
64
import time
75
import warnings
86
from functools import wraps
@@ -55,6 +53,8 @@ def rate_limited(max_per_second):
5553
If the limit is exceeded, the call will be held in a queue until
5654
enough time has passed.
5755
Useful when trying to avoid overloading a system with rapid calls."""
56+
import threading
57+
5858
min_interval = 1.0 / float(max_per_second)
5959

6060
def decorate(func):
@@ -88,23 +88,24 @@ def rate_limited_function(*args, **kargs):
8888
def deprecated(message=None):
8989
"""This decorator marks methods as deprecated.
9090
A warning is displayed if the method is called."""
91+
import inspect
9192

9293
def decorated_method_to_deprecate(func):
9394
if inspect.isclass(func):
9495
# Handle a deprecated class differently from a deprecated method
95-
msg = "Class {}() is DEPRECATED! *** ".format(func.__name__)
96+
msg = "Class {}() is DEPRECATED!".format(func.__name__)
9697
if message:
97-
msg += "<> %s <>" % message
98+
msg += " *** %s ***" % message
9899
warnings.simplefilter("always", DeprecationWarning) # See Warnings
99100
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
100101
warnings.simplefilter("default", DeprecationWarning) # Set Default
101102
return func
102103

103104
@wraps(func)
104105
def new_func(*args, **kwargs):
105-
msg = "Method {}() is DEPRECATED! *** ".format(func.__name__)
106+
msg = "Method {}() is DEPRECATED!".format(func.__name__)
106107
if message:
107-
msg += "<> %s <>" % message
108+
msg += " *** %s ***" % message
108109
warnings.simplefilter("always", DeprecationWarning) # See Warnings
109110
warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
110111
warnings.simplefilter("default", DeprecationWarning) # Set Default

seleniumbase/fixtures/base_case.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10095,12 +10095,9 @@ def __highlight_with_jquery_2(self, message, selector, o_bs):
1009510095

1009610096
from seleniumbase.common import decorators
1009710097

10098-
# Deprecated Methods (Replace these if they're still in your code!)
10099-
@decorators.deprecated(
10100-
"jq_format() is deprecated. Use re.escape() instead!"
10101-
)
10098+
@decorators.deprecated("You should use re.escape() instead.")
1010210099
def jq_format(self, code):
10103-
# DEPRECATED - re.escape() already performs the intended action!
10100+
# DEPRECATED - re.escape() already performs the intended action.
1010410101
return js_utils._jq_format(code)
1010510102

1010610103
############

seleniumbase/fixtures/js_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from selenium.common.exceptions import NoSuchElementException
99
from selenium.common.exceptions import WebDriverException
1010
from seleniumbase import config as sb_config
11-
from seleniumbase.common import decorators
1211
from seleniumbase.config import settings
1312
from seleniumbase.fixtures import constants
1413
from seleniumbase.fixtures import shared_utils
@@ -976,7 +975,6 @@ def clear_out_console_logs(driver):
976975
pass
977976

978977

979-
@decorators.deprecated("Use re.escape() instead, which does what you want!")
980978
def _jq_format(code):
981979
"""
982980
DEPRECATED - Use re.escape() instead, which performs the intended action.

0 commit comments

Comments
 (0)