(self)
| 1423 | self.assertIn("pymongo_test_bernie", dbs) |
| 1424 | |
| 1425 | def test_contextlib(self): |
| 1426 | client = self.rs_or_single_client() |
| 1427 | client.pymongo_test.drop_collection("test") |
| 1428 | client.pymongo_test.test.insert_one({"foo": "bar"}) |
| 1429 | |
| 1430 | # The socket used for the previous commands has been returned to the |
| 1431 | # pool |
| 1432 | self.assertEqual(1, len((get_pool(client)).conns)) |
| 1433 | |
| 1434 | # contextlib async support was added in Python 3.10 |
| 1435 | if _IS_SYNC or sys.version_info >= (3, 10): |
| 1436 | with contextlib.closing(client): |
| 1437 | self.assertEqual("bar", (client.pymongo_test.test.find_one())["foo"]) |
| 1438 | with self.assertRaises(InvalidOperation): |
| 1439 | client.pymongo_test.test.find_one() |
| 1440 | client = self.rs_or_single_client() |
| 1441 | with client as client: |
| 1442 | self.assertEqual("bar", (client.pymongo_test.test.find_one())["foo"]) |
| 1443 | with self.assertRaises(InvalidOperation): |
| 1444 | client.pymongo_test.test.find_one() |
| 1445 | |
| 1446 | @client_context.require_sync |
| 1447 | def test_interrupt_signal(self): |
nothing calls this directly
no test coverage detected