Skip to content

Commit

Permalink
Changed all bare excepts to use base Exception class (#2717)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaulv authored and AutomatedTester committed Sep 5, 2016
1 parent 73b4d1c commit 7e09cae
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions py/selenium/webdriver/chrome/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, executable_path="chromedriver", port=0,
command_executor=ChromeRemoteConnection(
remote_server_addr=self.service.service_url),
desired_capabilities=desired_capabilities)
except:
except Exception:
self.quit()
raise
self._is_remote = False
Expand All @@ -83,7 +83,7 @@ def quit(self):
"""
try:
RemoteWebDriver.quit(self)
except:
except Exception:
# We don't care about the message because something probably has gone wrong
pass
finally:
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def is_url_connectable(port):
return True
else:
return False
except:
except Exception:
return False


Expand Down
4 changes: 2 additions & 2 deletions py/selenium/webdriver/firefox/firefox_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ def _read_existing_userjs(self, userjs):
matches = re.search(PREF_RE, usr)
try:
self.default_preferences[matches.group(1)] = json.loads(matches.group(2))
except:
except Exception:
warnings.warn("(skipping) failed to json.loads existing preference: " +
matches.group(1) + matches.group(2))
except:
except Exception:
# The profile given hasn't had any changes made, i.e no users.js
pass

Expand Down
4 changes: 2 additions & 2 deletions py/selenium/webdriver/phantomjs/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, executable_path="phantomjs",
self,
command_executor=self.service.service_url,
desired_capabilities=desired_capabilities)
except:
except Exception:
self.quit()
raise

Expand All @@ -69,7 +69,7 @@ def quit(self):
"""
try:
RemoteWebDriver.quit(self)
except:
except Exception:
# We don't care about the message because something probably has gone wrong
pass
finally:
Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/remote/file_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ def is_local_file(self, *keys):
try:
if os.path.isfile(file_path):
return file_path
except:
except Exception:
pass
return None
4 changes: 2 additions & 2 deletions py/test/selenium/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def start_server(module):
_socket.connect((SERVER_ADDR, DEFAULT_PORT))
print("The remote driver server is already running or something else"
"is using port %d, continuing..." % DEFAULT_PORT)
except:
except Exception:
print("Starting the remote driver server")
module.server_proc = subprocess.Popen(
"java -jar %s" % SERVER_PATH,
Expand All @@ -63,5 +63,5 @@ def stop_server(module):
try:
os.kill(module.server_proc.pid, signal.SIGTERM)
time.sleep(5)
except:
except Exception:
pass
2 changes: 1 addition & 1 deletion py/test/selenium/webdriver/common/alerts_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,6 @@ def _loadPage(self, name):
try:
# just in case a previous test left open an alert
self.driver.switch_to.alert().dismiss()
except:
except Exception:
pass
self.driver.get(self._pageURL(name))
4 changes: 2 additions & 2 deletions py/test/selenium/webdriver/common/element_attribute_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def testShouldThrowExceptionIfSendingKeysToElementDisabledUsingRandomDisabledStr
try:
disabledTextElement1.send_keys("foo")
self.fail("Should have thrown exception")
except:
except Exception:
pass

self.assertEqual("", disabledTextElement1.text)
Expand All @@ -105,7 +105,7 @@ def testShouldThrowExceptionIfSendingKeysToElementDisabledUsingRandomDisabledStr
try:
disabledTextElement2.send_keys("bar")
self.fail("Should have thrown exception")
except:
except Exception:
pass
self.assertEqual("", disabledTextElement2.text)

Expand Down
2 changes: 1 addition & 1 deletion py/test/selenium/webdriver/common/interactions_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _isElementAvailable(self, id):
try:
self.driver.find_element_by_id(id)
return True
except:
except Exception:
return False

def testDragAndDrop(self):
Expand Down
2 changes: 1 addition & 1 deletion py/test/selenium/webdriver/common/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_interface_ip(ifname):
def get_lan_ip():
try:
ip = socket.gethostbyname(socket.gethostname())
except:
except Exception:
return '0.0.0.0'
if ip.startswith("127.") and os.name != "nt":
interfaces = ["eth0", "eth1", "eth2", "en0", "en1", "en2", "en3",
Expand Down
4 changes: 2 additions & 2 deletions py/test/selenium/webdriver/firefox/ff_profile_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_autodetect_proxy_is_set_in_profile(self):
def teardown_method(self, method):
try:
self.driver.quit()
except:
except Exception:
pass # don't care since we may have killed the browser above
self.webserver.stop()

Expand All @@ -226,5 +226,5 @@ def _loadPage(self, name):
def teardown_module(module):
try:
TestFirefoxProfile.driver.quit()
except:
except Exception:
pass # Don't Care since we may have killed the browser above
2 changes: 1 addition & 1 deletion py/test/selenium/webdriver/firefox/mn_binary_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ def test_invalid_binary_obj(self):
def teardown_method(self, method):
try:
self.driver.quit()
except:
except Exception:
pass
4 changes: 2 additions & 2 deletions py/test/selenium/webdriver/firefox/mn_launcher_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ def test_launch_and_close_browser(self):
def teardown_method(self, method):
try:
self.driver.quit()
except:
except Exception:
pass


def teardown_module(module):
try:
TestMarionetteLauncher.driver.quit()
except:
except Exception:
pass
4 changes: 2 additions & 2 deletions py/test/selenium/webdriver/firefox/mn_options_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def test_we_can_pass_options(self):
def teardown_method(self, method):
try:
self.driver.quit()
except:
except Exception:
pass # Don't care since we may have killed the browser above
self.webserver.stop()


def teardown_module(module):
try:
TestOptions.driver.quit()
except:
except Exception:
pass # Don't Care since we may have killed the browser above
4 changes: 2 additions & 2 deletions py/test/selenium/webdriver/firefox/mn_set_context_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ def teardown_method(self, method):
try:
self.driver.set_context(self.CONTENT)
self.driver.quit()
except:
except Exception:
pass # Don't care since we may have killed the browser above


def teardown_module(module):
try:
TestMarionetteSpecific.driver.quit()
except:
except Exception:
pass # Don't Care since we may have killed the browser above

0 comments on commit 7e09cae

Please sign in to comment.