Skip to content

Commit 3c640e8

Browse files
committed
temp changing pytests's setup and teardown are run to see if this will fix everything
1 parent dbb51e2 commit 3c640e8

8 files changed

+12
-8
lines changed

test/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,9 @@ def max_message_size_bytes(self):
861861

862862
def recreate_client_context():
863863
global client_context
864+
teardown()
864865
client_context = ClientContext()
865-
client_context.init()
866+
setup()
866867

867868

868869
class PyMongoTestCase(unittest.TestCase):
@@ -1233,6 +1234,8 @@ def tearDown(self):
12331234

12341235

12351236
def setup():
1237+
global client_context
1238+
client_context = ClientContext()
12361239
client_context.init()
12371240
warnings.resetwarnings()
12381241
warnings.simplefilter("always")

test/asynchronous/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,9 @@ async def max_message_size_bytes(self):
863863

864864
async def recreate_client_context():
865865
global async_client_context
866+
await async_teardown()
866867
async_client_context = AsyncClientContext()
867-
await async_client_context.init()
868+
await async_setup()
868869

869870

870871
class AsyncPyMongoTestCase(unittest.IsolatedAsyncioTestCase):
@@ -1251,6 +1252,8 @@ def tearDown(self):
12511252

12521253

12531254
async def async_setup():
1255+
global async_client_context
1256+
async_client_context = AsyncClientContext()
12541257
await async_client_context.init()
12551258
warnings.resetwarnings()
12561259
warnings.simplefilter("always")

test/asynchronous/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def event_loop_policy():
2424
return asyncio.get_event_loop_policy()
2525

2626

27-
@pytest_asyncio.fixture(scope="session", autouse=True)
27+
@pytest_asyncio.fixture(scope="module", autouse=True)
2828
async def test_setup_and_teardown():
2929
await async_setup()
3030
yield

test/asynchronous/test_connections_survive_primary_stepdown_spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async def _setup_class(cls):
6565
@classmethod
6666
async def _tearDown_class(cls):
6767
await cls.client.close()
68-
await recreate_client_context()
68+
# await recreate_client_context()
6969

7070
async def asyncSetUp(self):
7171
# Note that all ops use same write-concern as self.db (majority).

test/asynchronous/test_monitoring.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ async def test_not_primary_error(self):
413413
try:
414414
await client.pymongo_test.test.find_one_and_delete({})
415415
except NotPrimaryError as exc:
416-
print("an error was raised")
417416
error = exc.errors
418417
started = self.listener.started_events[0]
419418
failed = self.listener.failed_events[0]

test/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def event_loop_policy():
2222
return asyncio.get_event_loop_policy()
2323

2424

25-
@pytest.fixture(scope="session", autouse=True)
25+
@pytest.fixture(scope="module", autouse=True)
2626
def test_setup_and_teardown():
2727
setup()
2828
yield

test/test_connections_survive_primary_stepdown_spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _setup_class(cls):
6565
@classmethod
6666
def _tearDown_class(cls):
6767
cls.client.close()
68-
recreate_client_context()
68+
# recreate_client_context()
6969

7070
def setUp(self):
7171
# Note that all ops use same write-concern as self.db (majority).

test/test_monitoring.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ def test_not_primary_error(self):
413413
try:
414414
client.pymongo_test.test.find_one_and_delete({})
415415
except NotPrimaryError as exc:
416-
print("an error was raised")
417416
error = exc.errors
418417
started = self.listener.started_events[0]
419418
failed = self.listener.failed_events[0]

0 commit comments

Comments
 (0)