Skip to content

Commit 8da46dd

Browse files
authored
Merge pull request #137 from seleniumbase/reliability
Improve Reliability
2 parents 684c977 + 7cc4a38 commit 8da46dd

16 files changed

+62
-62
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ before_script:
2828
- sudo cp chromedriver /usr/local/bin/
2929
- sudo chmod +x /usr/local/bin/chromedriver
3030
script:
31-
- "nosetests examples/my_first_test.py --with-selenium --browser=chrome -s"
32-
- "pytest examples/my_first_test.py --with-selenium --browser=firefox -s"
33-
- "pytest examples/my_first_test.py --with-selenium --browser=phantomjs"
31+
- "nosetests examples/my_first_test.py --browser=chrome -s"
32+
- "pytest examples/my_first_test.py --browser=firefox -s"
33+
- "pytest examples/my_first_test.py --browser=phantomjs"
3434
notifications:
3535
email: false

examples/gui_test_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
try:
77
# Python 2
88
from Tkinter import Tk, Frame, Button, Label
9-
except:
9+
except Exception:
1010
# Python 3
1111
from tkinter import Tk, Frame, Button, Label
1212
import os

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ nose==1.3.7
66
pytest==3.4.0
77
pytest-html==1.16.1
88
six==1.10.0
9-
flake8==3.4.1
9+
flake8==3.5.0
1010
requests==2.18.4
1111
BeautifulSoup4==4.6.0
1212
unittest2==1.1.0

seleniumbase/common/encryption.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def str_xor(string, key):
1919
try:
2020
result = "".join(
2121
[chr(ord(c1) ^ ord(c2)) for (c1, c2) in zip(string, key)])
22-
except:
22+
except Exception:
2323
string = string.decode('utf-8')
2424
result = "".join(
2525
[chr(ord(c1) ^ ord(c2)) for (c1, c2) in zip(string, key)])
@@ -80,7 +80,7 @@ def ord_string_sum(string):
8080
try:
8181
for c in string:
8282
count += ord(c)
83-
except:
83+
except Exception:
8484
string = string.decode('utf-8')
8585
for c in string:
8686
count += ord(c)

seleniumbase/common/obfuscate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def main():
2626
time.sleep(0.07)
2727
print(encryption.decrypt(password))
2828
time.sleep(0.21)
29-
except:
29+
except KeyboardInterrupt:
3030
print("\nExiting...\n")
3131

3232

seleniumbase/common/unobfuscate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def main():
1616
try:
1717
# Python 2 has the raw_input() method. Python 3 does not.
1818
input_method = raw_input # noqa: ignore=F821
19-
except:
19+
except Exception:
2020
input_method = input # Using Python 3
2121
try:
2222
while(1):
@@ -26,7 +26,7 @@ def main():
2626
time.sleep(0.07)
2727
print(encryption.decrypt(code))
2828
time.sleep(0.21)
29-
except:
29+
except KeyboardInterrupt:
3030
print("\nExiting...\n")
3131

3232

seleniumbase/config/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# Default seconds to wait for page elements to appear before performing actions
1212
TINY_TIMEOUT = 0.1
1313
MINI_TIMEOUT = 2
14-
SMALL_TIMEOUT = 5
14+
SMALL_TIMEOUT = 6
1515
LARGE_TIMEOUT = 10
1616
EXTREME_TIMEOUT = 30
1717

seleniumbase/core/browser_launcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def get_local_driver(browser_name, headless):
147147
firefox_driver = webdriver.Firefox(
148148
firefox_profile=profile, capabilities=firefox_capabilities)
149149
return firefox_driver
150-
except:
150+
except Exception:
151151
return webdriver.Firefox()
152152
if browser_name == constants.Browser.INTERNET_EXPLORER:
153153
return webdriver.Ie()

seleniumbase/core/log_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def log_test_failure_data(test, test_logpath, driver, browser):
2626
traceback_list = traceback.format_list(
2727
traceback.extract_tb(traceback_address)[1:])
2828
traceback_message = ''.join(traceback_list).strip()
29-
except:
29+
except Exception:
3030
exc_message = "(Unknown Exception)"
3131
traceback_message = "(Unknown Traceback)"
3232
data_to_save.append("Traceback: " + traceback_message)

seleniumbase/core/s3_manager.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
class S3LoggingBucket(object):
1212
"""
13-
A class to upload our log files from tests to S3, from
14-
whence we can share them.
13+
A class to upload log files from tests to S3.
14+
Those files can then be shared easily.
1515
"""
1616

1717
def __init__(self,
@@ -26,16 +26,16 @@ def __init__(self,
2626
self.bucket_url = bucket_url
2727

2828
def get_key(self, _name):
29-
"""create a new Key instance with the given name"""
29+
""" Create a new Key instance with the given name. """
3030
return Key(bucket=self.bucket, name=_name)
3131

3232
def get_bucket(self):
33-
"""return the bucket we're using"""
33+
""" Return the bucket being used. """
3434
return self.bucket
3535

3636
def upload_file(self, file_name, file_path):
37-
"""upload a given file from the file_path to the bucket
38-
with the new name/path file_name"""
37+
""" Upload a given file from the file_path to the bucket
38+
with the new name/path file_name. """
3939
upload_key = Key(bucket=self.bucket, name=file_name)
4040
content_type = "text/plain"
4141
if file_name.endswith(".html"):
@@ -51,13 +51,13 @@ def upload_file(self, file_name, file_path):
5151
upload_key.generate_url(expires_in=3600).split("?")[0]
5252
try:
5353
upload_key.make_public()
54-
except:
54+
except Exception:
5555
pass
5656
return file_name
5757

5858
def upload_index_file(self, test_address, timestamp):
59-
"""create an index.html file with links to all the log files we
60-
just uploaded"""
59+
""" Create an index.html file with links to all the log files we
60+
just uploaded. """
6161
global already_uploaded_files
6262
already_uploaded_files = list(set(already_uploaded_files))
6363
already_uploaded_files.sort()
@@ -74,8 +74,8 @@ def upload_index_file(self, test_address, timestamp):
7474
return "%s%s" % (self.bucket_url, file_name)
7575

7676
def save_uploaded_file_names(self, files):
77-
"""We keep record of file names that have been uploaded. We upload log
78-
files related to each test after its execution. Once we're done, we
79-
use already_uploaded_files to create an index file"""
77+
""" Keep a record of all file names that've been uploaded. Upload log
78+
files related to each test after its execution. Once done, use
79+
already_uploaded_files to create an index file. """
8080
global already_uploaded_files
8181
already_uploaded_files.extend(files)

0 commit comments

Comments
 (0)