PYTHON-5259 - Better test assertions for error substrings (#2253)
This commit is contained in:
parent
e724d66bb5
commit
04ebbcde87
@ -2692,7 +2692,7 @@ class TestLookupProse(AsyncEncryptionIntegrationTest):
|
||||
]
|
||||
)
|
||||
)
|
||||
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 @@ class TestLookupProse(AsyncEncryptionIntegrationTest):
|
||||
]
|
||||
)
|
||||
)
|
||||
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
|
||||
|
||||
@ -450,7 +450,7 @@ class TestPooling(_TestPoolingBase):
|
||||
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 @@ class TestPooling(_TestPoolingBase):
|
||||
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 @@ class TestPooling(_TestPoolingBase):
|
||||
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),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -558,7 +558,7 @@ class TestBSON(unittest.TestCase):
|
||||
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.")
|
||||
|
||||
|
||||
@ -2676,7 +2676,7 @@ class TestLookupProse(EncryptionIntegrationTest):
|
||||
]
|
||||
)
|
||||
)
|
||||
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 @@ class TestLookupProse(EncryptionIntegrationTest):
|
||||
]
|
||||
)
|
||||
)
|
||||
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
|
||||
|
||||
@ -450,7 +450,7 @@ class TestPooling(_TestPoolingBase):
|
||||
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 @@ class TestPooling(_TestPoolingBase):
|
||||
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 @@ class TestPooling(_TestPoolingBase):
|
||||
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),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ class TestServer(unittest.TestCase):
|
||||
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__":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user