diff --git a/test/asynchronous/test_encryption.py b/test/asynchronous/test_encryption.py index 3b9096ef6a..f9b03f6303 100644 --- a/test/asynchronous/test_encryption.py +++ b/test/asynchronous/test_encryption.py @@ -2692,7 +2692,7 @@ async def test_8_csfle_joins_qe(self): ] ) ) - self.assertTrue("not supported" in str(exc)) + self.assertIn("not supported", str(exc)) @async_client_context.require_version_max(8, 1, -1) async def test_9_error(self): @@ -2721,7 +2721,7 @@ async def test_9_error(self): ] ) ) - self.assertTrue("Upgrade" in str(exc)) + self.assertIn("Upgrade", str(exc)) # https://github.com/mongodb/specifications/blob/072601/source/client-side-encryption/tests/README.md#rewrap diff --git a/test/asynchronous/test_pooling.py b/test/asynchronous/test_pooling.py index 81ed16f2d5..64c5738dba 100644 --- a/test/asynchronous/test_pooling.py +++ b/test/asynchronous/test_pooling.py @@ -450,7 +450,7 @@ async def test_csot_timeout_message(self): with timeout(0.5): await client.db.t.find_one({"$where": delay(2)}) - self.assertTrue("(configured timeouts: timeoutMS: 500.0ms" in str(error.exception)) + self.assertIn("(configured timeouts: timeoutMS: 500.0ms", str(error.exception)) @async_client_context.require_failCommand_appName async def test_socket_timeout_message(self): @@ -475,9 +475,9 @@ async def test_socket_timeout_message(self): with self.assertRaises(Exception) as error: await client.db.t.find_one({"$where": delay(2)}) - self.assertTrue( - "(configured timeouts: socketTimeoutMS: 500.0ms, connectTimeoutMS: 20000.0ms)" - in str(error.exception) + self.assertIn( + "(configured timeouts: socketTimeoutMS: 500.0ms, connectTimeoutMS: 20000.0ms)", + str(error.exception), ) @async_client_context.require_failCommand_appName @@ -507,9 +507,9 @@ async def test_connection_timeout_message(self): with self.assertRaises(Exception) as error: await client.admin.command("ping") - self.assertTrue( - "(configured timeouts: socketTimeoutMS: 500.0ms, connectTimeoutMS: 500.0ms)" - in str(error.exception) + self.assertIn( + "(configured timeouts: socketTimeoutMS: 500.0ms, connectTimeoutMS: 500.0ms)", + str(error.exception), ) diff --git a/test/test_bson.py b/test/test_bson.py index 6f26856b00..1616c513c2 100644 --- a/test/test_bson.py +++ b/test/test_bson.py @@ -558,7 +558,7 @@ def test_unknown_type(self): decode(bs) except Exception as exc: self.assertTrue(isinstance(exc, InvalidBSON)) - self.assertTrue(part in str(exc)) + self.assertIn(part, str(exc)) else: self.fail("Failed to raise an exception.") diff --git a/test/test_encryption.py b/test/test_encryption.py index 6d669a538d..5bbf8c8ad8 100644 --- a/test/test_encryption.py +++ b/test/test_encryption.py @@ -2676,7 +2676,7 @@ def test_8_csfle_joins_qe(self): ] ) ) - self.assertTrue("not supported" in str(exc)) + self.assertIn("not supported", str(exc)) @client_context.require_version_max(8, 1, -1) def test_9_error(self): @@ -2705,7 +2705,7 @@ def test_9_error(self): ] ) ) - self.assertTrue("Upgrade" in str(exc)) + self.assertIn("Upgrade", str(exc)) # https://github.com/mongodb/specifications/blob/072601/source/client-side-encryption/tests/README.md#rewrap diff --git a/test/test_pooling.py b/test/test_pooling.py index 44e8c4afe5..05513afe12 100644 --- a/test/test_pooling.py +++ b/test/test_pooling.py @@ -450,7 +450,7 @@ def test_csot_timeout_message(self): with timeout(0.5): client.db.t.find_one({"$where": delay(2)}) - self.assertTrue("(configured timeouts: timeoutMS: 500.0ms" in str(error.exception)) + self.assertIn("(configured timeouts: timeoutMS: 500.0ms", str(error.exception)) @client_context.require_failCommand_appName def test_socket_timeout_message(self): @@ -473,9 +473,9 @@ def test_socket_timeout_message(self): with self.assertRaises(Exception) as error: client.db.t.find_one({"$where": delay(2)}) - self.assertTrue( - "(configured timeouts: socketTimeoutMS: 500.0ms, connectTimeoutMS: 20000.0ms)" - in str(error.exception) + self.assertIn( + "(configured timeouts: socketTimeoutMS: 500.0ms, connectTimeoutMS: 20000.0ms)", + str(error.exception), ) @client_context.require_failCommand_appName @@ -505,9 +505,9 @@ def test_connection_timeout_message(self): with self.assertRaises(Exception) as error: client.admin.command("ping") - self.assertTrue( - "(configured timeouts: socketTimeoutMS: 500.0ms, connectTimeoutMS: 500.0ms)" - in str(error.exception) + self.assertIn( + "(configured timeouts: socketTimeoutMS: 500.0ms, connectTimeoutMS: 500.0ms)", + str(error.exception), ) diff --git a/test/test_server.py b/test/test_server.py index 45d01c10de..ab5a40a79b 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -31,7 +31,7 @@ def test_repr(self): hello = Hello({"ok": 1}) sd = ServerDescription(("localhost", 27017), hello) server = Server(sd, pool=object(), monitor=object()) # type: ignore[arg-type] - self.assertTrue("Standalone" in str(server)) + self.assertIn("Standalone", str(server)) if __name__ == "__main__":