diff --git a/test/asynchronous/qcheck.py b/test/asynchronous/qcheck.py index 190a7f1a9..deaf07b7e 100644 --- a/test/asynchronous/qcheck.py +++ b/test/asynchronous/qcheck.py @@ -237,7 +237,7 @@ async def check(predicate, generator): if not await predicate(case): reduction = await reduce(case, predicate) counter_examples.append("after {} reductions: {!r}".format(*reduction)) - except: + except Exception: counter_examples.append(f"{case!r} : {traceback.format_exc()}") return counter_examples diff --git a/test/asynchronous/test_custom_types.py b/test/asynchronous/test_custom_types.py index 82c54512c..d84c153ea 100644 --- a/test/asynchronous/test_custom_types.py +++ b/test/asynchronous/test_custom_types.py @@ -248,7 +248,7 @@ class TestBSONFallbackEncoder(unittest.TestCase): def fallback_encoder(value): try: return Decimal128(value) - except: + except Exception: raise TypeError("cannot encode type %s" % (type(value))) codecopts = self._get_codec_options(fallback_encoder) diff --git a/test/asynchronous/test_mongos_load_balancing.py b/test/asynchronous/test_mongos_load_balancing.py index 97170aa9e..174de15c7 100644 --- a/test/asynchronous/test_mongos_load_balancing.py +++ b/test/asynchronous/test_mongos_load_balancing.py @@ -153,7 +153,7 @@ class TestMongosLoadBalancing(AsyncMockClientTest): client.kill_host("{}:{}".format(*next(iter(client.nodes)))) try: await client.db.command("ping") - except: + except Exception: pass # We eventually connect to a new mongos. diff --git a/test/asynchronous/test_session.py b/test/asynchronous/test_session.py index 19ce868c5..a3d9016be 100644 --- a/test/asynchronous/test_session.py +++ b/test/asynchronous/test_session.py @@ -858,7 +858,7 @@ class TestCausalConsistency(AsyncUnitTest): self.listener.reset() try: await self.client.pymongo_test.command("doesntexist", session=sess) - except: + except Exception: pass failed = self.listener.failed_events[0] failed_op_time = failed.failure.get("operationTime") diff --git a/test/mod_wsgi_test/mod_wsgi_test.py b/test/mod_wsgi_test/mod_wsgi_test.py index 4ab2df244..384ed4ac6 100644 --- a/test/mod_wsgi_test/mod_wsgi_test.py +++ b/test/mod_wsgi_test/mod_wsgi_test.py @@ -43,7 +43,7 @@ try: from mod_wsgi import version as mod_wsgi_version # type: ignore[import] _HAVE_MOD_WSGI = True -except: +except Exception: mod_wsgi_version = None _HAVE_MOD_WSGI = False diff --git a/test/qcheck.py b/test/qcheck.py index 842580cbf..1957c0f1c 100644 --- a/test/qcheck.py +++ b/test/qcheck.py @@ -237,7 +237,7 @@ def check(predicate, generator): if not predicate(case): reduction = reduce(case, predicate) counter_examples.append("after {} reductions: {!r}".format(*reduction)) - except: + except Exception: counter_examples.append(f"{case!r} : {traceback.format_exc()}") return counter_examples diff --git a/test/test_custom_types.py b/test/test_custom_types.py index aba6b5511..331d8c7de 100644 --- a/test/test_custom_types.py +++ b/test/test_custom_types.py @@ -248,7 +248,7 @@ class TestBSONFallbackEncoder(unittest.TestCase): def fallback_encoder(value): try: return Decimal128(value) - except: + except Exception: raise TypeError("cannot encode type %s" % (type(value))) codecopts = self._get_codec_options(fallback_encoder) diff --git a/test/test_mongos_load_balancing.py b/test/test_mongos_load_balancing.py index 8c3185434..cd7379c50 100644 --- a/test/test_mongos_load_balancing.py +++ b/test/test_mongos_load_balancing.py @@ -153,7 +153,7 @@ class TestMongosLoadBalancing(MockClientTest): client.kill_host("{}:{}".format(*next(iter(client.nodes)))) try: client.db.command("ping") - except: + except Exception: pass # We eventually connect to a new mongos. diff --git a/test/test_session.py b/test/test_session.py index 40d0a53af..a56ed90c9 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -858,7 +858,7 @@ class TestCausalConsistency(UnitTest): self.listener.reset() try: self.client.pymongo_test.command("doesntexist", session=sess) - except: + except Exception: pass failed = self.listener.failed_events[0] failed_op_time = failed.failure.get("operationTime") diff --git a/test/test_threads.py b/test/test_threads.py index 3e469e28f..5cb4c4ed4 100644 --- a/test/test_threads.py +++ b/test/test_threads.py @@ -72,7 +72,7 @@ class Insert(threading.Thread): try: self.collection.insert_one({"test": "insert"}) error = False - except: + except Exception: if not self.expect_exception: raise @@ -95,7 +95,7 @@ class Update(threading.Thread): try: self.collection.update_one({"test": "unique"}, {"$set": {"test": "update"}}) error = False - except: + except Exception: if not self.expect_exception: raise