summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2018-09-07 17:59:46 -0700
committerToshio Kuratomi <a.badger@gmail.com>2018-12-16 15:03:19 -0800
commit3fba0062078cc04eabb460ec1eb13a4739235199 (patch)
tree9c09103ce103a90f97ccf3736ca6c2502d7860f8 /test
parent5147e792d398258a5a87c3271ea89c1c4fd2f4d3 (diff)
downloadansible-3fba0062078cc04eabb460ec1eb13a4739235199.tar.gz
Update bare exceptions to specify Exception.
This will keep us from accidentally catching program-exiting exceptions like KeyboardInterupt and SystemExit.
Diffstat (limited to 'test')
-rw-r--r--test/legacy/consul_running.py2
-rw-r--r--test/runner/lib/thread.py5
-rw-r--r--test/units/module_utils/ec2/test_aws.py2
-rw-r--r--test/units/modules/net_tools/nios/test_nios_module.py2
-rw-r--r--test/units/modules/network/aireos/aireos_module.py2
-rw-r--r--test/units/modules/network/aruba/aruba_module.py2
-rw-r--r--test/units/modules/network/cnos/cnos_module.py2
-rw-r--r--test/units/modules/network/dellos10/dellos10_module.py2
-rw-r--r--test/units/modules/network/dellos6/dellos6_module.py2
-rw-r--r--test/units/modules/network/dellos9/dellos9_module.py2
-rw-r--r--test/units/modules/network/edgeos/edgeos_module.py2
-rw-r--r--test/units/modules/network/edgeswitch/edgeswitch_module.py2
-rw-r--r--test/units/modules/network/enos/enos_module.py2
-rw-r--r--test/units/modules/network/eos/eos_module.py2
-rw-r--r--test/units/modules/network/exos/exos_module.py2
-rw-r--r--test/units/modules/network/ingate/ingate_module.py2
-rw-r--r--test/units/modules/network/ios/ios_module.py2
-rw-r--r--test/units/modules/network/iosxr/iosxr_module.py2
-rw-r--r--test/units/modules/network/ironware/ironware_module.py2
-rw-r--r--test/units/modules/network/junos/junos_module.py4
-rw-r--r--test/units/modules/network/netvisor/nvos_module.py2
-rw-r--r--test/units/modules/network/nos/nos_module.py2
-rw-r--r--test/units/modules/network/nxos/nxos_module.py2
-rw-r--r--test/units/modules/network/onyx/onyx_module.py2
-rw-r--r--test/units/modules/network/opx/opx_module.py2
-rw-r--r--test/units/modules/network/ovs/ovs_module.py2
-rw-r--r--test/units/modules/network/routeros/routeros_module.py2
-rw-r--r--test/units/modules/network/slxos/slxos_module.py2
-rw-r--r--test/units/modules/network/voss/voss_module.py2
-rw-r--r--test/units/modules/network/vyos/vyos_module.py2
-rw-r--r--test/units/modules/packaging/os/test_apt.py2
-rw-r--r--test/units/parsing/utils/test_addresses.py4
-rw-r--r--test/units/plugins/lookup/test_conjur_variable.py6
-rw-r--r--test/units/plugins/lookup/test_onepassword.py2
34 files changed, 41 insertions, 38 deletions
diff --git a/test/legacy/consul_running.py b/test/legacy/consul_running.py
index f64aaeecc3..0772cd4046 100644
--- a/test/legacy/consul_running.py
+++ b/test/legacy/consul_running.py
@@ -7,5 +7,5 @@ if __name__ == '__main__':
consul = consul.Consul(host='0.0.0.0', port=8500)
consul.catalog.nodes()
print("True")
- except:
+ except Exception:
pass
diff --git a/test/runner/lib/thread.py b/test/runner/lib/thread.py
index ce4717e008..8a287790a2 100644
--- a/test/runner/lib/thread.py
+++ b/test/runner/lib/thread.py
@@ -30,10 +30,13 @@ class WrappedThread(threading.Thread):
Run action and capture results or exception.
Do not override. Do not call directly. Executed by the start() method.
"""
+ # We truly want to catch anything that the worker thread might do including call sys.exit.
+ # Therefore we catch *everything* (including old-style class exceptions)
# noinspection PyBroadException, PyPep8
try:
self._result.put((self.action(), None))
- except: # pylint: disable=locally-disabled, bare-except
+ # pylint: disable=locally-disabled, bare-except
+ except: # noqa
self._result.put((None, sys.exc_info()))
def wait_for_result(self):
diff --git a/test/units/module_utils/ec2/test_aws.py b/test/units/module_utils/ec2/test_aws.py
index d7e7ffbed0..6e566eee85 100644
--- a/test/units/module_utils/ec2/test_aws.py
+++ b/test/units/module_utils/ec2/test_aws.py
@@ -20,7 +20,7 @@ try:
import boto3
import botocore
HAS_BOTO3 = True
-except:
+except Exception:
HAS_BOTO3 = False
import pytest
diff --git a/test/units/modules/net_tools/nios/test_nios_module.py b/test/units/modules/net_tools/nios/test_nios_module.py
index 3ad9705c6f..dbf5885173 100644
--- a/test/units/modules/net_tools/nios/test_nios_module.py
+++ b/test/units/modules/net_tools/nios/test_nios_module.py
@@ -40,7 +40,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/aireos/aireos_module.py b/test/units/modules/network/aireos/aireos_module.py
index 5fc6c93578..1ac1b5275c 100644
--- a/test/units/modules/network/aireos/aireos_module.py
+++ b/test/units/modules/network/aireos/aireos_module.py
@@ -39,7 +39,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/aruba/aruba_module.py b/test/units/modules/network/aruba/aruba_module.py
index d11d7d4393..9d305b6b41 100644
--- a/test/units/modules/network/aruba/aruba_module.py
+++ b/test/units/modules/network/aruba/aruba_module.py
@@ -40,7 +40,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/cnos/cnos_module.py b/test/units/modules/network/cnos/cnos_module.py
index bc1428fff0..e31cedd7cc 100644
--- a/test/units/modules/network/cnos/cnos_module.py
+++ b/test/units/modules/network/cnos/cnos_module.py
@@ -44,7 +44,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/dellos10/dellos10_module.py b/test/units/modules/network/dellos10/dellos10_module.py
index 4521bb2e38..24698d20a2 100644
--- a/test/units/modules/network/dellos10/dellos10_module.py
+++ b/test/units/modules/network/dellos10/dellos10_module.py
@@ -42,7 +42,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/dellos6/dellos6_module.py b/test/units/modules/network/dellos6/dellos6_module.py
index 7f0b3da4b4..2323a02dd9 100644
--- a/test/units/modules/network/dellos6/dellos6_module.py
+++ b/test/units/modules/network/dellos6/dellos6_module.py
@@ -40,7 +40,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/dellos9/dellos9_module.py b/test/units/modules/network/dellos9/dellos9_module.py
index 4bf092c7ae..2dfa9d7eb6 100644
--- a/test/units/modules/network/dellos9/dellos9_module.py
+++ b/test/units/modules/network/dellos9/dellos9_module.py
@@ -42,7 +42,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/edgeos/edgeos_module.py b/test/units/modules/network/edgeos/edgeos_module.py
index 59c7b3e3fc..dfab2974f4 100644
--- a/test/units/modules/network/edgeos/edgeos_module.py
+++ b/test/units/modules/network/edgeos/edgeos_module.py
@@ -39,7 +39,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/edgeswitch/edgeswitch_module.py b/test/units/modules/network/edgeswitch/edgeswitch_module.py
index 1731bc6817..37c8b8aa28 100644
--- a/test/units/modules/network/edgeswitch/edgeswitch_module.py
+++ b/test/units/modules/network/edgeswitch/edgeswitch_module.py
@@ -39,7 +39,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/enos/enos_module.py b/test/units/modules/network/enos/enos_module.py
index c97cd5cc35..a7af81c3c2 100644
--- a/test/units/modules/network/enos/enos_module.py
+++ b/test/units/modules/network/enos/enos_module.py
@@ -43,7 +43,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/eos/eos_module.py b/test/units/modules/network/eos/eos_module.py
index d9d5d44fa2..3ae2aa5e64 100644
--- a/test/units/modules/network/eos/eos_module.py
+++ b/test/units/modules/network/eos/eos_module.py
@@ -40,7 +40,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/exos/exos_module.py b/test/units/modules/network/exos/exos_module.py
index 067df1e014..da4ece7e6c 100644
--- a/test/units/modules/network/exos/exos_module.py
+++ b/test/units/modules/network/exos/exos_module.py
@@ -39,7 +39,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/ingate/ingate_module.py b/test/units/modules/network/ingate/ingate_module.py
index 6e11cadbdc..acdda8e99e 100644
--- a/test/units/modules/network/ingate/ingate_module.py
+++ b/test/units/modules/network/ingate/ingate_module.py
@@ -41,7 +41,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/ios/ios_module.py b/test/units/modules/network/ios/ios_module.py
index f450c4ad26..7a63d5d82a 100644
--- a/test/units/modules/network/ios/ios_module.py
+++ b/test/units/modules/network/ios/ios_module.py
@@ -40,7 +40,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/iosxr/iosxr_module.py b/test/units/modules/network/iosxr/iosxr_module.py
index a8229ca3df..55f2a23688 100644
--- a/test/units/modules/network/iosxr/iosxr_module.py
+++ b/test/units/modules/network/iosxr/iosxr_module.py
@@ -40,7 +40,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/ironware/ironware_module.py b/test/units/modules/network/ironware/ironware_module.py
index a66a7754b4..918e75b2d3 100644
--- a/test/units/modules/network/ironware/ironware_module.py
+++ b/test/units/modules/network/ironware/ironware_module.py
@@ -41,7 +41,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/junos/junos_module.py b/test/units/modules/network/junos/junos_module.py
index b0701b1fe2..055b40a4d4 100644
--- a/test/units/modules/network/junos/junos_module.py
+++ b/test/units/modules/network/junos/junos_module.py
@@ -44,12 +44,12 @@ def load_fixture(name, content='xml'):
data = f.read()
try:
data = json.load(path)
- except:
+ except Exception:
pass
else:
try:
data = parse(path).getroot()
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/netvisor/nvos_module.py b/test/units/modules/network/netvisor/nvos_module.py
index cef888a255..614d59440a 100644
--- a/test/units/modules/network/netvisor/nvos_module.py
+++ b/test/units/modules/network/netvisor/nvos_module.py
@@ -30,7 +30,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/nos/nos_module.py b/test/units/modules/network/nos/nos_module.py
index bc9e56580f..80a24f01fc 100644
--- a/test/units/modules/network/nos/nos_module.py
+++ b/test/units/modules/network/nos/nos_module.py
@@ -39,7 +39,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/nxos/nxos_module.py b/test/units/modules/network/nxos/nxos_module.py
index 342ec550d0..7a9871be8c 100644
--- a/test/units/modules/network/nxos/nxos_module.py
+++ b/test/units/modules/network/nxos/nxos_module.py
@@ -50,7 +50,7 @@ def load_fixture(module_name, name, device=''):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/onyx/onyx_module.py b/test/units/modules/network/onyx/onyx_module.py
index 2234ae5f0d..cee5e0c683 100644
--- a/test/units/modules/network/onyx/onyx_module.py
+++ b/test/units/modules/network/onyx/onyx_module.py
@@ -39,7 +39,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/opx/opx_module.py b/test/units/modules/network/opx/opx_module.py
index 7b5ed21cb0..3741771f0e 100644
--- a/test/units/modules/network/opx/opx_module.py
+++ b/test/units/modules/network/opx/opx_module.py
@@ -42,7 +42,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/ovs/ovs_module.py b/test/units/modules/network/ovs/ovs_module.py
index fe49809d50..7864d9308f 100644
--- a/test/units/modules/network/ovs/ovs_module.py
+++ b/test/units/modules/network/ovs/ovs_module.py
@@ -40,7 +40,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/routeros/routeros_module.py b/test/units/modules/network/routeros/routeros_module.py
index 3ddd33a135..cf9a3dfe2d 100644
--- a/test/units/modules/network/routeros/routeros_module.py
+++ b/test/units/modules/network/routeros/routeros_module.py
@@ -40,7 +40,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/slxos/slxos_module.py b/test/units/modules/network/slxos/slxos_module.py
index e2d3d4401b..8cd482ed11 100644
--- a/test/units/modules/network/slxos/slxos_module.py
+++ b/test/units/modules/network/slxos/slxos_module.py
@@ -39,7 +39,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/voss/voss_module.py b/test/units/modules/network/voss/voss_module.py
index 93df60f1b6..d5ca438c06 100644
--- a/test/units/modules/network/voss/voss_module.py
+++ b/test/units/modules/network/voss/voss_module.py
@@ -40,7 +40,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/network/vyos/vyos_module.py b/test/units/modules/network/vyos/vyos_module.py
index 264cd5c66e..138c684e88 100644
--- a/test/units/modules/network/vyos/vyos_module.py
+++ b/test/units/modules/network/vyos/vyos_module.py
@@ -40,7 +40,7 @@ def load_fixture(name):
try:
data = json.loads(data)
- except:
+ except Exception:
pass
fixture_data[path] = data
diff --git a/test/units/modules/packaging/os/test_apt.py b/test/units/modules/packaging/os/test_apt.py
index e4ebcfafaa..4c4874f017 100644
--- a/test/units/modules/packaging/os/test_apt.py
+++ b/test/units/modules/packaging/os/test_apt.py
@@ -9,7 +9,7 @@ try:
from ansible.modules.packaging.os.apt import (
expand_pkgspec_from_fnmatches,
)
-except:
+except Exception:
# Need some more module_utils work (porting urls.py) before we can test
# modules. So don't error out in this case.
if sys.version_info[0] >= 3:
diff --git a/test/units/parsing/utils/test_addresses.py b/test/units/parsing/utils/test_addresses.py
index e7b60efa1c..ea86c55423 100644
--- a/test/units/parsing/utils/test_addresses.py
+++ b/test/units/parsing/utils/test_addresses.py
@@ -74,7 +74,7 @@ class TestParseAddress(unittest.TestCase):
try:
(host, port) = parse_address(t)
- except:
+ except Exception:
host = None
port = None
@@ -87,7 +87,7 @@ class TestParseAddress(unittest.TestCase):
try:
(host, port) = parse_address(t, allow_ranges=True)
- except:
+ except Exception:
host = None
port = None
diff --git a/test/units/plugins/lookup/test_conjur_variable.py b/test/units/plugins/lookup/test_conjur_variable.py
index c2fa87c781..98890f82ab 100644
--- a/test/units/plugins/lookup/test_conjur_variable.py
+++ b/test/units/plugins/lookup/test_conjur_variable.py
@@ -68,7 +68,7 @@ class TestLookupModule:
mock_response = MagicMock(spec_set=http_client.HTTPResponse)
try:
mock_response.getcode.return_value = 200
- except:
+ except Exception:
# HTTPResponse is a Python 3 only feature. This uses a generic mock for python 2.6
mock_response = MagicMock()
mock_response.getcode.return_value = 200
@@ -83,7 +83,7 @@ class TestLookupModule:
mock_response = MagicMock(spec_set=http_client.HTTPResponse)
try:
mock_response.getcode.return_value = 200
- except:
+ except Exception:
# HTTPResponse is a Python 3 only feature. This uses a generic mock for python 2.6
mock_response = MagicMock()
mock_response.getcode.return_value = 200
@@ -99,7 +99,7 @@ class TestLookupModule:
mock_response = MagicMock(spec_set=http_client.HTTPResponse)
try:
mock_response.getcode.return_value = code
- except:
+ except Exception:
# HTTPResponse is a Python 3 only feature. This uses a generic mock for python 2.6
mock_response = MagicMock()
mock_response.getcode.return_value = code
diff --git a/test/units/plugins/lookup/test_onepassword.py b/test/units/plugins/lookup/test_onepassword.py
index 0f67c8bc42..5db40fb78f 100644
--- a/test/units/plugins/lookup/test_onepassword.py
+++ b/test/units/plugins/lookup/test_onepassword.py
@@ -218,7 +218,7 @@ class TestOnePass(unittest.TestCase):
op = MockOnePass()
try:
op.assert_logged_in()
- except:
+ except Exception:
self.fail()
def test_onepassword_logged_out(self):