Skip to content

Commit 5293f54

Browse files
committed
Refactoring
1 parent aa0732d commit 5293f54

35 files changed

+50
-172
lines changed

seleniumbase/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from seleniumbase.plugins.sb_manager import SB # noqa
1919
from seleniumbase.plugins.driver_manager import Driver # noqa
2020
from seleniumbase.plugins.driver_manager import DriverContext # noqa
21+
from seleniumbase import translate # noqa
2122

2223
if sys.version_info[0] < 3 and "pdbp" in locals():
2324
# With Python3, "import pdbp" is all you need
@@ -33,8 +34,6 @@
3334
pdb.DefaultConfig.enable_hidden_frames = False
3435
pdb.DefaultConfig.truncate_long_lines = True
3536
pdb.DefaultConfig.sticky_by_default = True
36-
if sys.version_info[0] >= 3:
37-
from seleniumbase import translate # noqa
3837
if sys.version_info >= (3, 7):
3938
webdriver.TouchActions = None # Lifeline for past selenium-wire versions
4039
if sys.version_info >= (3, 10):

seleniumbase/behave/behave_helper.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
# -*- coding: utf-8 -*-
2-
import sys
3-
4-
python3 = True
5-
if sys.version_info[0] < 3:
6-
python3 = False
1+
"""Generating Gherkin-formatted code from the Recorder."""
72

83

94
def generate_gherkin(srt_actions):
105
sb_actions = []
116
for action in srt_actions:
127
if action[0] == "begin" or action[0] == "_url_":
13-
if "%" in action[2] and python3:
8+
if "%" in action[2]:
149
try:
1510
from urllib.parse import unquote
1611

@@ -24,7 +19,7 @@ def generate_gherkin(srt_actions):
2419
else:
2520
sb_actions.append('Open "%s"' % action[2].replace('"', '\\"'))
2621
elif action[0] == "f_url":
27-
if "%" in action[2] and python3:
22+
if "%" in action[2]:
2823
try:
2924
from urllib.parse import unquote
3025

seleniumbase/common/encryption.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# -\*- coding: utf-8 -\*-
2-
3-
""" This is mainly for string obfuscation. """
1+
"""This is mainly for string obfuscation."""
42

53
import base64
64
import codecs

seleniumbase/common/unobfuscate.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,11 @@
99
"""
1010

1111
from seleniumbase.common import encryption
12-
import sys
1312
import time
1413

1514

1615
def main():
17-
if sys.version_info[0] >= 3:
18-
input_method = input # Using Python 3 (or higher)
19-
else:
20-
# Python 2 has the raw_input() method. Python 3 does not.
21-
input_method = raw_input # noqa: ignore=F821
16+
input_method = input
2217
try:
2318
while 1:
2419
code = input_method(

seleniumbase/console_scripts/rich_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def display_markdown(code):
1919
try:
2020
markdown = Markdown(code)
2121
console = Console()
22-
console.print(markdown) # noqa
22+
console.print(markdown)
2323
return True # Success
2424
except Exception:
2525
return False # Failure
@@ -28,7 +28,7 @@ def display_markdown(code):
2828
def display_code(code):
2929
try:
3030
console = Console()
31-
console.print(code) # noqa
31+
console.print(code)
3232
return True # Success
3333
except Exception:
3434
return False # Failure

seleniumbase/console_scripts/sb_behave_gui.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Launches SeleniumBase Behave Commander | GUI for Behave.
43

seleniumbase/console_scripts/sb_caseplans.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Launches the SeleniumBase Case Plans Generator.
43

seleniumbase/console_scripts/sb_commander.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Launches SeleniumBase Commander | GUI for pytest.
43

seleniumbase/console_scripts/sb_mkchart.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Creates a new SeleniumBase chart presentation with boilerplate code.
43

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
Creates a new folder for running SeleniumBase scripts.
43
@@ -493,10 +492,7 @@ def main():
493492
data.append("")
494493
data.append("class BaseTestCase(BaseCase):")
495494
data.append(" def setUp(self):")
496-
if sys.version_info[0] >= 3:
497-
data.append(" super().setUp()")
498-
else:
499-
data.append(" super(BaseTestCase, self).setUp()")
495+
data.append(" super().setUp()")
500496
data.append(" # <<< Run custom code AFTER the super() line >>>")
501497
data.append("")
502498
data.append(" def tearDown(self):")
@@ -509,10 +505,7 @@ def main():
509505
data.append(" pass")
510506
data.append(" # (Wrap unreliable code in a try/except block.)")
511507
data.append(" # <<< Run custom code BEFORE the super() line >>>")
512-
if sys.version_info[0] >= 3:
513-
data.append(" super().tearDown()")
514-
else:
515-
data.append(" super(BaseTestCase, self).tearDown()")
508+
data.append(" super().tearDown()")
516509
data.append("")
517510
data.append(" def login(self):")
518511
data.append(" # <<< Placeholder. Add your code here. >>>")

0 commit comments

Comments
 (0)