Merge pull request #237 from seleniumbase/flake8-updates

Upgrade flake8 version and make fixes based on it
This commit is contained in:
Michael Mintz 2018-11-05 00:36:29 -05:00 committed by GitHub
commit bac1ba59be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 58 additions and 60 deletions

View File

@ -18,6 +18,6 @@ parameterized==0.6.1
beautifulsoup4>=4.6.0
pyotp>=2.2.6
boto>=2.49.0
flake8==3.5.0
flake8==3.6.0
PyVirtualDisplay==0.2.1
-e .

View File

@ -118,18 +118,18 @@ def decrypt(string):
rem4 = (len(string) + ord_string_sum(string)) % 2
if len(string) % 2 != 0:
if rem3 == 1:
string = (chr(ord(string[-1]) - 5 - rem1) + string +
chr(ord(string[-1]) - 13 - rem1))
string = (chr(ord(string[-1]) - 5 - rem1) + string + ''
'' + chr(ord(string[-1]) - 13 - rem1))
else:
string = (chr(ord(string[-1]) - 11 - rem1) + string +
chr(ord(string[-1]) - 23 - rem1))
string = (chr(ord(string[-1]) - 11 - rem1) + string + ''
'' + chr(ord(string[-1]) - 23 - rem1))
elif len(string) > 1:
if rem4 == 1:
string = (chr(ord(string[0]) - 19 + rem2) + string +
chr(ord(string[0]) - 7 - rem2))
string = (chr(ord(string[0]) - 19 + rem2) + string + ''
'' + chr(ord(string[0]) - 7 - rem2))
else:
string = (chr(ord(string[0]) - 26 + rem2) + string +
chr(ord(string[0]) - 12 - rem2))
string = (chr(ord(string[0]) - 26 + rem2) + string + ''
'' + chr(ord(string[0]) - 12 - rem2))
rem5 = (len(string) + ord_string_sum(string)) % 23
string = rotate(string, rem5)
result = str_xor(shuffle_string(string)[::-1], xor_key)

View File

@ -64,7 +64,7 @@ class S3LoggingBucket(object):
index = self.get_key(file_name)
index_str = []
for completed_file in already_uploaded_files:
index_str.append("<a href='" + self.bucket_url +
index_str.append("<a href='" + self.bucket_url + ""
"%s'>%s</a>" % (completed_file, completed_file))
index.set_contents_from_string(
"<br>".join(index_str),

View File

@ -278,8 +278,8 @@ def play_shepherd_tour(driver, tour_steps, msg_dur, name=None, interval=0):
stop_ms = start_ms + (interval * 1000.0)
now_ms = time.time() * 1000.0
if now_ms >= stop_ms:
if ((element == latest_element) and
(shep_text == latest_text)):
if ((element == latest_element) and (
shep_text == latest_text)):
driver.execute_script("Shepherd.activeTour.next()")
try:
latest_element = driver.execute_script(

View File

@ -2793,9 +2793,9 @@ class BaseCase(unittest.TestCase):
test_logpath = self.log_path + "/" + test_id
if not os.path.exists(test_logpath):
os.makedirs(test_logpath)
if ((not self.with_screen_shots) and
(not self.with_basic_test_info) and
(not self.with_page_source)):
if ((not self.with_screen_shots) and (
not self.with_basic_test_info) and (
not self.with_page_source)):
# Log everything if nothing specified (if testing_base)
log_helper.log_screenshot(test_logpath, self.driver)
log_helper.log_test_failure_data(

View File

@ -478,7 +478,7 @@ class EmailManager:
except KeyError:
pass
return text # leave as is
return re.sub("&#?\w+;", fixup, html)
return re.sub(r"&#?\w+;", fixup, html)
def decode_quoted_printable(self, html):
"""

View File

@ -129,8 +129,8 @@ def activate_jquery(driver):
def are_quotes_escaped(string):
if (string.count("\\'") != string.count("'") or
string.count('\\"') != string.count('"')):
if (string.count("\\'") != string.count("'") or (
string.count('\\"') != string.count('"'))):
return True
return False

View File

@ -24,9 +24,8 @@ def is_xpath_selector(selector):
"""
A basic method to determine if a selector is an xpath selector.
"""
if (selector.startswith('/') or
selector.startswith('./') or
selector.startswith('(')):
if (selector.startswith('/') or selector.startswith('./') or (
selector.startswith('('))):
return True
return False
@ -35,8 +34,7 @@ def is_link_text_selector(selector):
"""
A basic method to determine if a selector is a link text selector.
"""
if (selector.startswith('link=') or
selector.startswith('link_text=')):
if (selector.startswith('link=') or selector.startswith('link_text=')):
return True
return False

View File

@ -5,27 +5,27 @@ Convert XPath selectors into CSS selectors
import re
_sub_regexes = {
"tag": "([a-zA-Z][a-zA-Z0-9]{0,10}|\*)",
"attribute": "[.a-zA-Z_:][-\w:.]*(\(\))?)",
"value": "\s*[\w/:][-/\w\s,:;.]*"
"tag": r"([a-zA-Z][a-zA-Z0-9]{0,10}|\*)",
"attribute": r"[.a-zA-Z_:][-\w:.]*(\(\))?)",
"value": r"\s*[\w/:][-/\w\s,:;.]*"
}
_validation_re = (
"(?P<node>"
"("
"^id\([\"\']?(?P<idvalue>%(value)s)[\"\']?\)"
"|"
"(?P<nav>//?)(?P<tag>%(tag)s)"
"(\[("
"(?P<matched>(?P<mattr>@?%(attribute)s=[\"\']"
"(?P<mvalue>%(value)s))[\"\']"
"|"
"(?P<contained>contains\((?P<cattr>@?%(attribute)s,\s*[\"\']"
"(?P<cvalue>%(value)s)[\"\']\))"
")\])?"
"(\[(?P<nth>\d)\])?"
")"
")" % _sub_regexes
r"(?P<node>"
r"("
r"^id\([\"\']?(?P<idvalue>%(value)s)[\"\']?\)"
r"|"
r"(?P<nav>//?)(?P<tag>%(tag)s)"
r"(\[("
r"(?P<matched>(?P<mattr>@?%(attribute)s=[\"\']"
r"(?P<mvalue>%(value)s))[\"\']"
r"|"
r"(?P<contained>contains\((?P<cattr>@?%(attribute)s,\s*[\"\']"
r"(?P<cvalue>%(value)s)[\"\']\))"
r")\])?"
r"(\[(?P<nth>\d)\])?"
r")"
r")" % _sub_regexes
)
prog = re.compile(_validation_re)
@ -136,11 +136,11 @@ def convert_xpath_to_css(xpath):
css = _get_raw_css_from_xpath(xpath)
attribute_defs = re.findall('(\[\w+\=\S+\])', css)
attribute_defs = re.findall(r'(\[\w+\=\S+\])', css)
for attr_def in attribute_defs:
if (attr_def.count('[') == 1 and attr_def.count(']') == 1 and
attr_def.count('=') == 1 and attr_def.count('"') == 0 and
attr_def.count("'") == 0) and attr_def.count(' ') == 0:
if (attr_def.count('[') == 1 and attr_def.count(']') == 1 and (
attr_def.count('=') == 1) and attr_def.count('"') == 0 and (
attr_def.count("'") == 0)) and attr_def.count(' ') == 0:
# Now safe to manipulate
q1 = attr_def.find('=') + 1
q2 = attr_def.find(']')

View File

@ -122,9 +122,9 @@ class Base(Plugin):
specified (basic_test_info, screen_shots, page_source), then save them
all by default. Otherwise, save only selected ones from their plugins.
"""
if ((not self.options.enable_plugin_basic_test_info) and
(not self.options.enable_plugin_screen_shots) and
(not self.options.enable_plugin_page_source)):
if ((not self.options.enable_plugin_basic_test_info) and (
not self.options.enable_plugin_screen_shots) and (
not self.options.enable_plugin_page_source)):
test_logpath = self.options.log_path + "/" + test.id()
log_helper.log_screenshot(test_logpath, test.driver)
log_helper.log_test_failure_data(
@ -165,9 +165,9 @@ class Base(Plugin):
error states, we want to make sure that they don't show up in
the nose output as errors.
"""
if (err[0] == errors.BlockedTest or
err[0] == errors.SkipTest or
err[0] == errors.DeprecatedTest):
if (err[0] == errors.BlockedTest or (
err[0] == errors.SkipTest) or (
err[0] == errors.DeprecatedTest)):
print(err[1].__str__().split('''-------------------- >> '''
'''begin captured logging'''
''' << --------------------''', 1)[0])

View File

@ -589,14 +589,14 @@ def main():
selector = re.escape(selector)
selector = js_utils.escape_quotes_if_needed(selector)
if int(line_num) < num_lines - 1:
regex_string = (r'''^\s*self.click\(["|']''' +
selector + r'''["|']\)\s*$''')
regex_string = (r'''^\s*self.click\(["|']'''
'' + selector + r'''["|']\)\s*$''')
data2 = re.match(regex_string, lines[line_num + 1])
if data2:
continue
regex_string = (r'''^\s*self.update_text\(["|']''' +
selector +
r'''["|'], [\S\s]+\)\s*$''')
regex_string = (r'''^\s*self.update_text\(["|']'''
'' + selector + ''
'' + r'''["|'], [\S\s]+\)\s*$''')
data2 = re.match(regex_string, lines[line_num + 1])
if data2:
continue
@ -617,8 +617,8 @@ def main():
link_text = re.escape(link_text)
link_text = js_utils.escape_quotes_if_needed(link_text)
if int(line_num) < num_lines - 2:
regex_string = (r'''^\s*self.click\(["|']link=''' +
link_text + r'''["|']\)\s*$''')
regex_string = (r'''^\s*self.click\(["|']link='''
'' + link_text + r'''["|']\)\s*$''')
data2 = re.match(regex_string, lines[line_num + 1])
if data2:
continue

View File

@ -17,7 +17,7 @@ except IOError:
setup(
name='seleniumbase',
version='1.17.1',
version='1.17.2',
description='All-in-One Test Automation Framework',
long_description=long_description,
long_description_content_type='text/markdown',
@ -70,7 +70,7 @@ setup(
'beautifulsoup4>=4.6.0', # Keep at >=4.6.0 while using bs4
'pyotp>=2.2.6',
'boto>=2.49.0',
'flake8==3.5.0',
'flake8==3.6.0',
'PyVirtualDisplay==0.2.1',
],
packages=[