diff --git a/test/test_encryption.py b/test/test_encryption.py index 00f76b7c9..e4372d7e5 100644 --- a/test/test_encryption.py +++ b/test/test_encryption.py @@ -329,6 +329,25 @@ class TestClientSimple(EncryptionIntegrationTest): with self.assertRaisesRegex(InvalidOperation, "Cannot use MongoClient after close"): client.admin.command("ping") + # Not available for versions of Python without "register_at_fork" + @unittest.skipIf( + not hasattr(os, "register_at_fork"), + "register_at_fork not available in this version of Python", + ) + def test_fork(self): + opts = AutoEncryptionOpts(KMS_PROVIDERS, "keyvault.datakeys") + client = rs_or_single_client(auto_encryption_opts=opts) + + lock_pid = os.fork() + if lock_pid == 0: + client.admin.command("ping") + client.close() + os._exit(0) + else: + self.assertEqual(0, os.waitpid(lock_pid, 0)[1]) + client.admin.command("ping") + client.close() + class TestEncryptedBulkWrite(BulkTestBase, EncryptionIntegrationTest): def test_upsert_uuid_standard_encrypt(self): diff --git a/test/test_fork.py b/test/test_fork.py index 7180e1a23..b1c98a26f 100644 --- a/test/test_fork.py +++ b/test/test_fork.py @@ -53,7 +53,7 @@ class TestFork(IntegrationTest): if lock_pid == 0: os._exit(exit_cond()) else: - self.assertEqual(0, os.waitpid(lock_pid, 0)[1] >> 8) + self.assertEqual(0, os.waitpid(lock_pid, 0)[1]) def test_lock_object_id(self): """ @@ -67,7 +67,7 @@ class TestFork(IntegrationTest): if lock_pid == 0: os._exit(int(ObjectId._inc_lock.locked())) else: - self.assertEqual(0, os.waitpid(lock_pid, 0)[1] >> 8) + self.assertEqual(0, os.waitpid(lock_pid, 0)[1]) def test_topology_reset(self): """ @@ -92,7 +92,7 @@ class TestFork(IntegrationTest): ) os._exit(0) else: # Parent - self.assertEqual(0, os.waitpid(lock_pid, 0)[1] >> 8) + self.assertEqual(0, os.waitpid(lock_pid, 0)[1]) self.assertEqual(self.client._topology._pid, init_id) child_id = parent_conn.recv() self.assertNotEqual(child_id, init_id)