PYTHON-3403 Skips unit test if eventlent or gevent is imported (#1039)

This commit is contained in:
Ben Warner 2022-08-18 12:15:44 -07:00 committed by GitHub
parent 4170dc958e
commit dd3b4b11d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -51,6 +51,7 @@ from test.utils import (
TestCreator,
TopologyEventListener,
camel_to_snake_args,
is_greenthread_patched,
rs_or_single_client,
wait_until,
)
@ -334,6 +335,10 @@ class TestClientSimple(EncryptionIntegrationTest):
not hasattr(os, "register_at_fork"),
"register_at_fork not available in this version of Python",
)
@unittest.skipIf(
is_greenthread_patched(),
"gevent and eventlet do not support POSIX-style forking.",
)
def test_fork(self):
opts = AutoEncryptionOpts(KMS_PROVIDERS, "keyvault.datakeys")
client = rs_or_single_client(auto_encryption_opts=opts)

View File

@ -17,7 +17,11 @@
import os
from multiprocessing import Pipe
from test import IntegrationTest, client_context
from test.utils import ExceptionCatchingThread, rs_or_single_client
from test.utils import (
ExceptionCatchingThread,
is_greenthread_patched,
rs_or_single_client,
)
from unittest import skipIf
from bson.objectid import ObjectId
@ -32,6 +36,10 @@ def setUpModule():
@skipIf(
not hasattr(os, "register_at_fork"), "register_at_fork not available in this version of Python"
)
@skipIf(
is_greenthread_patched(),
"gevent and eventlet do not support POSIX-style forking.",
)
class TestFork(IntegrationTest):
def test_lock_client(self):
"""
@ -156,5 +164,8 @@ class TestFork(IntegrationTest):
for t in threads:
t.join()
for t in threads:
self.assertIsNone(t.exc)
for c in clients:
c.close()