Skip to content

Commit dd3b4b1

Browse files
authored
PYTHON-3403 Skips unit test if eventlent or gevent is imported (#1039)
1 parent 4170dc9 commit dd3b4b1

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

test/test_encryption.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
TestCreator,
5252
TopologyEventListener,
5353
camel_to_snake_args,
54+
is_greenthread_patched,
5455
rs_or_single_client,
5556
wait_until,
5657
)
@@ -334,6 +335,10 @@ def test_use_after_close(self):
334335
not hasattr(os, "register_at_fork"),
335336
"register_at_fork not available in this version of Python",
336337
)
338+
@unittest.skipIf(
339+
is_greenthread_patched(),
340+
"gevent and eventlet do not support POSIX-style forking.",
341+
)
337342
def test_fork(self):
338343
opts = AutoEncryptionOpts(KMS_PROVIDERS, "keyvault.datakeys")
339344
client = rs_or_single_client(auto_encryption_opts=opts)

test/test_fork.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
import os
1818
from multiprocessing import Pipe
1919
from test import IntegrationTest, client_context
20-
from test.utils import ExceptionCatchingThread, rs_or_single_client
20+
from test.utils import (
21+
ExceptionCatchingThread,
22+
is_greenthread_patched,
23+
rs_or_single_client,
24+
)
2125
from unittest import skipIf
2226

2327
from bson.objectid import ObjectId
@@ -32,6 +36,10 @@ def setUpModule():
3236
@skipIf(
3337
not hasattr(os, "register_at_fork"), "register_at_fork not available in this version of Python"
3438
)
39+
@skipIf(
40+
is_greenthread_patched(),
41+
"gevent and eventlet do not support POSIX-style forking.",
42+
)
3543
class TestFork(IntegrationTest):
3644
def test_lock_client(self):
3745
"""
@@ -156,5 +164,8 @@ def action(client):
156164
for t in threads:
157165
t.join()
158166

167+
for t in threads:
168+
self.assertIsNone(t.exc)
169+
159170
for c in clients:
160171
c.close()

0 commit comments

Comments
 (0)