Skip to content

Commit

Permalink
making flake8 compliant by not having naked expects (d2iq-archive#5716)
Browse files Browse the repository at this point in the history
  • Loading branch information
kensipe authored Nov 3, 2017
1 parent bb06d45 commit c2858dc
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/test/python/app_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def handle_sigterm(signum, frame):
os.system("ps -a | grep $(lsof -ti :{})".format(port))
else:
logging.exception("Socket.error in the main thread: ")
except:
except Exception:
logging.exception("Exception in the main thread: ")
finally:
logging.info("Closing the server...")
Expand Down
12 changes: 6 additions & 6 deletions tests/scale/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def time_deployment(test=""):
deployment_count = len(deployments)
if deployment_count > 0:
time.sleep(1)
except:
except Exception:
wait_for_service_endpoint('marathon-user')
pass

Expand Down Expand Up @@ -226,7 +226,7 @@ def instance_test_app(test_obj):
launch_results = test_obj.launch_results
try:
launch_apps(test_obj)
except:
except Exception:
# service unavail == wait for marathon
launch_results.failed('Failure to launched (but we still will wait for deploys)')
wait_for_marathon_up(test_obj)
Expand Down Expand Up @@ -312,7 +312,7 @@ def undeployment_wait(test_obj=None):
if deployment_count > 0:
time.sleep(1)
failure_count = 0
except:
except Exception:
failure_count += 1
# consecutive failures great than x
if failure_count > 10 and test_obj is not None:
Expand Down Expand Up @@ -527,7 +527,7 @@ def get_cluster_metadata():

try:
version = ee_version()
except:
except Exception:
version = None

resources = available_resources()
Expand Down Expand Up @@ -583,7 +583,7 @@ def uninstall_mom():
dcos_client = mesos.DCOSClient()
dcos_client.shutdown_framework(framework_id)
time.sleep(2)
except:
except Exception:
pass

removed = False
Expand Down Expand Up @@ -620,7 +620,7 @@ def wait_for_marathon_up(test_obj=None, timeout=60 * 5):
def quiet_wait_for_marathon_up(test_obj=None, timeout=60 * 5):
try:
wait_for_marathon_up(test_obj, timeout)
except:
except Exception:
pass


Expand Down
2 changes: 1 addition & 1 deletion tests/scale/over-provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
run_command(agent, "sudo rm -f /var/lib/mesos/slave/meta/slaves/latest")
try:
start_agent(agent)
except:
except Exception:
time.sleep(1)
start_agent(agent)
2 changes: 1 addition & 1 deletion tests/scale/test_root_marathon_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def teardown_module(module):
create_scale_graph(stats, metadata)
try:
delete_all_apps_wait()
except:
except Exception:
pass


Expand Down
12 changes: 6 additions & 6 deletions tests/system/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def cluster_info(mom_name='marathon-user'):
client = marathon.create_client()
about = client.get_about()
print("Marathon MoM version: {}".format(about.get("version")))
except:
except Exception:
print("Marathon MoM not present")
else:
print("Marathon MoM not present")
Expand Down Expand Up @@ -196,7 +196,7 @@ def ensure_mom():
try:
shakedown.install_package_and_wait('marathon')
shakedown.deployment_wait()
except:
except Exception:
pass

if not shakedown.wait_for_service_endpoint('marathon-user'):
Expand Down Expand Up @@ -248,7 +248,7 @@ def wait_for_task(service, task, timeout_sec=120):
response = None
try:
response = shakedown.get_service_task(service, task)
except:
except Exception:
pass

if response is not None and response['state'] == 'TASK_RUNNING':
Expand All @@ -267,7 +267,7 @@ def clear_pods():
for pod in pods:
client.remove_pod(pod["id"], True)
shakedown.deployment_wait()
except:
except Exception:
pass


Expand Down Expand Up @@ -603,7 +603,7 @@ def set_service_account_permissions(service_account, resource='dcos:superuser',
else:
print("Unexpected HTTP error: {}".format(e.response))
raise
except:
except Exception:
print("Unexpected error:", sys.exc_info()[0])
raise

Expand All @@ -625,7 +625,7 @@ def add_acs_resource(resource):
else:
print("Unexpected HTTP error: {}, {}".format(e.response, e.response.text))
raise
except:
except Exception:
print("Unexpected error:", sys.exc_info()[0])
raise

Expand Down
2 changes: 1 addition & 1 deletion tests/system/marathon_common_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def test_unhealthy_app_can_be_rolled_back():

try:
shakedown.deployment_wait()
except:
except Exception:
client.rollback_deployment(deployment_id)
shakedown.deployment_wait()

Expand Down
2 changes: 1 addition & 1 deletion tests/system/marathon_pods_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def test_remove_pod():

try:
client.show_pod(pod_id)
except:
except Exception:
pass
else:
assert False, "The pod has not been removed"
Expand Down
4 changes: 2 additions & 2 deletions tests/system/scripts/pinger.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ def do_GET(self):
return self.handle_relay()
else:
return self.handle_ping()
except:
except Exception:
logging.exception('Could not handle GET request')
raise

def do_POST(self):
try:
logging.debug("Got POST request")
return self.handle_ping()
except:
except Exception:
logging.exception('Could not handle POST request')
raise

Expand Down
4 changes: 2 additions & 2 deletions tests/system/test_marathon_on_marathon.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def teardown_module(module):
with shakedown.marathon_on_marathon():
try:
common.clean_up_marathon()
except:
except Exception:
pass

shakedown.uninstall_package_and_wait('marathon')
Expand Down Expand Up @@ -243,7 +243,7 @@ def test_framework_unavailable_on_mom():

try:
shakedown.wait_for_service_endpoint('pyfw', 15)
except:
except Exception:
pass
else:
assert False, 'MoM shoud NOT create a service endpoint'
Expand Down
2 changes: 1 addition & 1 deletion tests/system/test_marathon_on_marathon_ee.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def mom_ee_image(version):
image_name = 'MOM_EE_{}'.format(version)
try:
os.environ[image_name]
except:
except Exception:
default_image = DEFAULT_MOM_IMAGES[image_name]
print('No environment override found for MoM-EE v{}. Using default image {}'.format(version, default_image))
return default_image
Expand Down
4 changes: 2 additions & 2 deletions tests/system/test_marathon_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def remove_app(app_id):

try:
client.get_app(app_id)
except:
except Exception:
pass
else:
assert False, "The application resurrected"
Expand All @@ -143,7 +143,7 @@ def remove_app(app_id):
# check if app definition is still not there
try:
client.get_app(app_id)
except:
except Exception:
pass
else:
assert False, "The application resurrected"
Expand Down

0 comments on commit c2858dc

Please sign in to comment.