Skip to content

Commit c08fceb

Browse files
committed
PYTHON-5071 Fix setup
1 parent eb75d77 commit c08fceb

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

test/__init__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,8 @@ def reset_client_context():
880880

881881
class PyMongoTestCase(unittest.TestCase):
882882
if not _IS_SYNC:
883-
# Customize async TestCase to use a single event loop for all tests.
883+
# An async TestCase that uses a single event loop for all tests.
884+
# Inspired by TestCase.
884885
def __init__(self, methodName="runTest"):
885886
super().__init__(methodName)
886887
try:
@@ -900,16 +901,11 @@ def addCleanup(self, func, /, *args, **kwargs):
900901
self.addCleanup(*(func, *args), **kwargs)
901902

902903
def _callSetUp(self):
904+
self.setUp()
903905
self._callAsync(self.setUp)
904906

905907
def _callTestMethod(self, method):
906-
if self._callMaybeAsync(method) is not None:
907-
warnings.warn(
908-
f"It is deprecated to return a value that is not None from a "
909-
f"test case ({method})",
910-
DeprecationWarning,
911-
stacklevel=4,
912-
)
908+
self._callMaybeAsync(method)
913909

914910
def _callTearDown(self):
915911
self._callAsync(self.tearDown)

test/asynchronous/__init__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,8 @@ async def reset_client_context():
882882

883883
class AsyncPyMongoTestCase(unittest.TestCase):
884884
if not _IS_SYNC:
885-
# Customize async TestCase to use a single event loop for all tests.
885+
# An async TestCase that uses a single event loop for all tests.
886+
# Inspired by IsolatedAsyncioTestCase.
886887
def __init__(self, methodName="runTest"):
887888
super().__init__(methodName)
888889
try:
@@ -902,16 +903,11 @@ def addAsyncCleanup(self, func, /, *args, **kwargs):
902903
self.addCleanup(*(func, *args), **kwargs)
903904

904905
def _callSetUp(self):
906+
self.setUp()
905907
self._callAsync(self.asyncSetUp)
906908

907909
def _callTestMethod(self, method):
908-
if self._callMaybeAsync(method) is not None:
909-
warnings.warn(
910-
f"It is deprecated to return a value that is not None from a "
911-
f"test case ({method})",
912-
DeprecationWarning,
913-
stacklevel=4,
914-
)
910+
self._callMaybeAsync(method)
915911

916912
def _callTearDown(self):
917913
self._callAsync(self.asyncTearDown)

0 commit comments

Comments
 (0)