Skip to content

Commit bac1ba5

Browse files
authored
Merge pull request #237 from seleniumbase/flake8-updates
Upgrade flake8 version and make fixes based on it
2 parents a02f54d + 4d52f87 commit bac1ba5

File tree

12 files changed

+58
-60
lines changed

12 files changed

+58
-60
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ parameterized==0.6.1
1818
beautifulsoup4>=4.6.0
1919
pyotp>=2.2.6
2020
boto>=2.49.0
21-
flake8==3.5.0
21+
flake8==3.6.0
2222
PyVirtualDisplay==0.2.1
2323
-e .

seleniumbase/common/encryption.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@ def decrypt(string):
118118
rem4 = (len(string) + ord_string_sum(string)) % 2
119119
if len(string) % 2 != 0:
120120
if rem3 == 1:
121-
string = (chr(ord(string[-1]) - 5 - rem1) + string +
122-
chr(ord(string[-1]) - 13 - rem1))
121+
string = (chr(ord(string[-1]) - 5 - rem1) + string + ''
122+
'' + chr(ord(string[-1]) - 13 - rem1))
123123
else:
124-
string = (chr(ord(string[-1]) - 11 - rem1) + string +
125-
chr(ord(string[-1]) - 23 - rem1))
124+
string = (chr(ord(string[-1]) - 11 - rem1) + string + ''
125+
'' + chr(ord(string[-1]) - 23 - rem1))
126126
elif len(string) > 1:
127127
if rem4 == 1:
128-
string = (chr(ord(string[0]) - 19 + rem2) + string +
129-
chr(ord(string[0]) - 7 - rem2))
128+
string = (chr(ord(string[0]) - 19 + rem2) + string + ''
129+
'' + chr(ord(string[0]) - 7 - rem2))
130130
else:
131-
string = (chr(ord(string[0]) - 26 + rem2) + string +
132-
chr(ord(string[0]) - 12 - rem2))
131+
string = (chr(ord(string[0]) - 26 + rem2) + string + ''
132+
'' + chr(ord(string[0]) - 12 - rem2))
133133
rem5 = (len(string) + ord_string_sum(string)) % 23
134134
string = rotate(string, rem5)
135135
result = str_xor(shuffle_string(string)[::-1], xor_key)

seleniumbase/core/s3_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def upload_index_file(self, test_address, timestamp):
6464
index = self.get_key(file_name)
6565
index_str = []
6666
for completed_file in already_uploaded_files:
67-
index_str.append("<a href='" + self.bucket_url +
67+
index_str.append("<a href='" + self.bucket_url + ""
6868
"%s'>%s</a>" % (completed_file, completed_file))
6969
index.set_contents_from_string(
7070
"<br>".join(index_str),

seleniumbase/core/tour_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ def play_shepherd_tour(driver, tour_steps, msg_dur, name=None, interval=0):
278278
stop_ms = start_ms + (interval * 1000.0)
279279
now_ms = time.time() * 1000.0
280280
if now_ms >= stop_ms:
281-
if ((element == latest_element) and
282-
(shep_text == latest_text)):
281+
if ((element == latest_element) and (
282+
shep_text == latest_text)):
283283
driver.execute_script("Shepherd.activeTour.next()")
284284
try:
285285
latest_element = driver.execute_script(

seleniumbase/fixtures/base_case.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,9 +2793,9 @@ def tearDown(self):
27932793
test_logpath = self.log_path + "/" + test_id
27942794
if not os.path.exists(test_logpath):
27952795
os.makedirs(test_logpath)
2796-
if ((not self.with_screen_shots) and
2797-
(not self.with_basic_test_info) and
2798-
(not self.with_page_source)):
2796+
if ((not self.with_screen_shots) and (
2797+
not self.with_basic_test_info) and (
2798+
not self.with_page_source)):
27992799
# Log everything if nothing specified (if testing_base)
28002800
log_helper.log_screenshot(test_logpath, self.driver)
28012801
log_helper.log_test_failure_data(

seleniumbase/fixtures/email_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def fixup(text):
478478
except KeyError:
479479
pass
480480
return text # leave as is
481-
return re.sub("&#?\w+;", fixup, html)
481+
return re.sub(r"&#?\w+;", fixup, html)
482482

483483
def decode_quoted_printable(self, html):
484484
"""

seleniumbase/fixtures/js_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ def activate_jquery(driver):
129129

130130

131131
def are_quotes_escaped(string):
132-
if (string.count("\\'") != string.count("'") or
133-
string.count('\\"') != string.count('"')):
132+
if (string.count("\\'") != string.count("'") or (
133+
string.count('\\"') != string.count('"'))):
134134
return True
135135
return False
136136

seleniumbase/fixtures/page_utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ def is_xpath_selector(selector):
2424
"""
2525
A basic method to determine if a selector is an xpath selector.
2626
"""
27-
if (selector.startswith('/') or
28-
selector.startswith('./') or
29-
selector.startswith('(')):
27+
if (selector.startswith('/') or selector.startswith('./') or (
28+
selector.startswith('('))):
3029
return True
3130
return False
3231

@@ -35,8 +34,7 @@ def is_link_text_selector(selector):
3534
"""
3635
A basic method to determine if a selector is a link text selector.
3736
"""
38-
if (selector.startswith('link=') or
39-
selector.startswith('link_text=')):
37+
if (selector.startswith('link=') or selector.startswith('link_text=')):
4038
return True
4139
return False
4240

seleniumbase/fixtures/xpath_to_css.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55
import re
66

77
_sub_regexes = {
8-
"tag": "([a-zA-Z][a-zA-Z0-9]{0,10}|\*)",
9-
"attribute": "[.a-zA-Z_:][-\w:.]*(\(\))?)",
10-
"value": "\s*[\w/:][-/\w\s,:;.]*"
8+
"tag": r"([a-zA-Z][a-zA-Z0-9]{0,10}|\*)",
9+
"attribute": r"[.a-zA-Z_:][-\w:.]*(\(\))?)",
10+
"value": r"\s*[\w/:][-/\w\s,:;.]*"
1111
}
1212

1313
_validation_re = (
14-
"(?P<node>"
15-
"("
16-
"^id\([\"\']?(?P<idvalue>%(value)s)[\"\']?\)"
17-
"|"
18-
"(?P<nav>//?)(?P<tag>%(tag)s)"
19-
"(\[("
20-
"(?P<matched>(?P<mattr>@?%(attribute)s=[\"\']"
21-
"(?P<mvalue>%(value)s))[\"\']"
22-
"|"
23-
"(?P<contained>contains\((?P<cattr>@?%(attribute)s,\s*[\"\']"
24-
"(?P<cvalue>%(value)s)[\"\']\))"
25-
")\])?"
26-
"(\[(?P<nth>\d)\])?"
27-
")"
28-
")" % _sub_regexes
14+
r"(?P<node>"
15+
r"("
16+
r"^id\([\"\']?(?P<idvalue>%(value)s)[\"\']?\)"
17+
r"|"
18+
r"(?P<nav>//?)(?P<tag>%(tag)s)"
19+
r"(\[("
20+
r"(?P<matched>(?P<mattr>@?%(attribute)s=[\"\']"
21+
r"(?P<mvalue>%(value)s))[\"\']"
22+
r"|"
23+
r"(?P<contained>contains\((?P<cattr>@?%(attribute)s,\s*[\"\']"
24+
r"(?P<cvalue>%(value)s)[\"\']\))"
25+
r")\])?"
26+
r"(\[(?P<nth>\d)\])?"
27+
r")"
28+
r")" % _sub_regexes
2929
)
3030

3131
prog = re.compile(_validation_re)
@@ -136,11 +136,11 @@ def convert_xpath_to_css(xpath):
136136

137137
css = _get_raw_css_from_xpath(xpath)
138138

139-
attribute_defs = re.findall('(\[\w+\=\S+\])', css)
139+
attribute_defs = re.findall(r'(\[\w+\=\S+\])', css)
140140
for attr_def in attribute_defs:
141-
if (attr_def.count('[') == 1 and attr_def.count(']') == 1 and
142-
attr_def.count('=') == 1 and attr_def.count('"') == 0 and
143-
attr_def.count("'") == 0) and attr_def.count(' ') == 0:
141+
if (attr_def.count('[') == 1 and attr_def.count(']') == 1 and (
142+
attr_def.count('=') == 1) and attr_def.count('"') == 0 and (
143+
attr_def.count("'") == 0)) and attr_def.count(' ') == 0:
144144
# Now safe to manipulate
145145
q1 = attr_def.find('=') + 1
146146
q2 = attr_def.find(']')

seleniumbase/plugins/base_plugin.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ def __log_all_options_if_none_specified(self, test):
122122
specified (basic_test_info, screen_shots, page_source), then save them
123123
all by default. Otherwise, save only selected ones from their plugins.
124124
"""
125-
if ((not self.options.enable_plugin_basic_test_info) and
126-
(not self.options.enable_plugin_screen_shots) and
127-
(not self.options.enable_plugin_page_source)):
125+
if ((not self.options.enable_plugin_basic_test_info) and (
126+
not self.options.enable_plugin_screen_shots) and (
127+
not self.options.enable_plugin_page_source)):
128128
test_logpath = self.options.log_path + "/" + test.id()
129129
log_helper.log_screenshot(test_logpath, test.driver)
130130
log_helper.log_test_failure_data(
@@ -165,9 +165,9 @@ def addError(self, test, err, capt=None):
165165
error states, we want to make sure that they don't show up in
166166
the nose output as errors.
167167
"""
168-
if (err[0] == errors.BlockedTest or
169-
err[0] == errors.SkipTest or
170-
err[0] == errors.DeprecatedTest):
168+
if (err[0] == errors.BlockedTest or (
169+
err[0] == errors.SkipTest) or (
170+
err[0] == errors.DeprecatedTest)):
171171
print(err[1].__str__().split('''-------------------- >> '''
172172
'''begin captured logging'''
173173
''' << --------------------''', 1)[0])

seleniumbase/utilities/selenium_ide/convert_ide.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,14 +589,14 @@ def main():
589589
selector = re.escape(selector)
590590
selector = js_utils.escape_quotes_if_needed(selector)
591591
if int(line_num) < num_lines - 1:
592-
regex_string = (r'''^\s*self.click\(["|']''' +
593-
selector + r'''["|']\)\s*$''')
592+
regex_string = (r'''^\s*self.click\(["|']'''
593+
'' + selector + r'''["|']\)\s*$''')
594594
data2 = re.match(regex_string, lines[line_num + 1])
595595
if data2:
596596
continue
597-
regex_string = (r'''^\s*self.update_text\(["|']''' +
598-
selector +
599-
r'''["|'], [\S\s]+\)\s*$''')
597+
regex_string = (r'''^\s*self.update_text\(["|']'''
598+
'' + selector + ''
599+
'' + r'''["|'], [\S\s]+\)\s*$''')
600600
data2 = re.match(regex_string, lines[line_num + 1])
601601
if data2:
602602
continue
@@ -617,8 +617,8 @@ def main():
617617
link_text = re.escape(link_text)
618618
link_text = js_utils.escape_quotes_if_needed(link_text)
619619
if int(line_num) < num_lines - 2:
620-
regex_string = (r'''^\s*self.click\(["|']link=''' +
621-
link_text + r'''["|']\)\s*$''')
620+
regex_string = (r'''^\s*self.click\(["|']link='''
621+
'' + link_text + r'''["|']\)\s*$''')
622622
data2 = re.match(regex_string, lines[line_num + 1])
623623
if data2:
624624
continue

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
setup(
1919
name='seleniumbase',
20-
version='1.17.1',
20+
version='1.17.2',
2121
description='All-in-One Test Automation Framework',
2222
long_description=long_description,
2323
long_description_content_type='text/markdown',
@@ -70,7 +70,7 @@
7070
'beautifulsoup4>=4.6.0', # Keep at >=4.6.0 while using bs4
7171
'pyotp>=2.2.6',
7272
'boto>=2.49.0',
73-
'flake8==3.5.0',
73+
'flake8==3.6.0',
7474
'PyVirtualDisplay==0.2.1',
7575
],
7676
packages=[

0 commit comments

Comments
 (0)