File tree Expand file tree Collapse file tree 5 files changed +15
-11
lines changed Expand file tree Collapse file tree 5 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,9 @@ def __init__(self):
127
127
server_api = ServerApi (MONGODB_API_VERSION )
128
128
self .default_client_options ["server_api" ] = server_api
129
129
130
+ def reset (self ):
131
+ self .__init__ ()
132
+
130
133
@property
131
134
def client_options (self ):
132
135
"""Return the MongoClient options for creating a duplicate client."""
@@ -859,13 +862,12 @@ def max_message_size_bytes(self):
859
862
client_context = ClientContext ()
860
863
861
864
862
- def recreate_client_context ():
865
+ def reset_client_context ():
863
866
if _IS_SYNC :
864
867
# sync tests don't need to recreate a client context
865
868
return
866
- global client_context
867
869
teardown ()
868
- client_context = ClientContext ()
870
+ client_context . reset ()
869
871
setup ()
870
872
871
873
Original file line number Diff line number Diff line change @@ -127,6 +127,9 @@ def __init__(self):
127
127
server_api = ServerApi (MONGODB_API_VERSION )
128
128
self .default_client_options ["server_api" ] = server_api
129
129
130
+ def reset (self ):
131
+ self .__init__ ()
132
+
130
133
@property
131
134
def client_options (self ):
132
135
"""Return the MongoClient options for creating a duplicate client."""
@@ -861,13 +864,12 @@ async def max_message_size_bytes(self):
861
864
async_client_context = AsyncClientContext ()
862
865
863
866
864
- async def recreate_client_context ():
867
+ async def reset_client_context ():
865
868
if _IS_SYNC :
866
869
# sync tests don't need to recreate a client context
867
870
return
868
- global async_client_context
869
871
await async_teardown ()
870
- async_client_context = AsyncClientContext ()
872
+ async_client_context . reset ()
871
873
await async_setup ()
872
874
873
875
Original file line number Diff line number Diff line change 22
22
from test .asynchronous import (
23
23
AsyncIntegrationTest ,
24
24
async_client_context ,
25
- recreate_client_context ,
25
+ reset_client_context ,
26
26
unittest ,
27
27
)
28
28
from test .asynchronous .helpers import async_repl_set_step_down
@@ -65,7 +65,7 @@ async def _setup_class(cls):
65
65
@classmethod
66
66
async def _tearDown_class (cls ):
67
67
await cls .client .close ()
68
- await recreate_client_context ()
68
+ await reset_client_context ()
69
69
70
70
async def asyncSetUp (self ):
71
71
# Note that all ops use same write-concern as self.db (majority).
Original file line number Diff line number Diff line change 22
22
from test import (
23
23
IntegrationTest ,
24
24
client_context ,
25
- recreate_client_context ,
25
+ reset_client_context ,
26
26
unittest ,
27
27
)
28
28
from test .helpers import repl_set_step_down
@@ -65,7 +65,7 @@ def _setup_class(cls):
65
65
@classmethod
66
66
def _tearDown_class (cls ):
67
67
cls .client .close ()
68
- recreate_client_context ()
68
+ reset_client_context ()
69
69
70
70
def setUp (self ):
71
71
# Note that all ops use same write-concern as self.db (majority).
Original file line number Diff line number Diff line change 29
29
wait_until ,
30
30
)
31
31
32
- from pymongo .synchronous . periodic_executor import _EXECUTORS
32
+ from pymongo .periodic_executor import _EXECUTORS
33
33
34
34
35
35
def unregistered (ref ):
You can’t perform that action at this time.
0 commit comments