MOTOR-1315 Fix compatibility with pytest 8.1 (#278)

This commit is contained in:
Steven Silvester 2024-05-15 09:51:12 -05:00 committed by GitHub
parent 0248600e38
commit 6ee75e08f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 27 additions and 12 deletions

View File

@ -89,7 +89,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.7
python-version: 3.8
cache: 'pip'
cache-dependency-path: 'pyproject.toml'
- name: Install Python dependencies

View File

@ -1257,8 +1257,6 @@ another, if the remote host requires authentication.
For this, use PyMongo's ``copy_database`` method, or, since PyMongo's
``copy_database`` will be removed in a future release too, use the mongo shell.
.. seealso:: `The "copydb" command <https://mongodb.com/docs/manual/reference/command/copydb/>`_.
Motor 0.3.3
-----------

View File

@ -85,6 +85,9 @@ filterwarnings = [
"ignore:The next_object method is deprecated:DeprecationWarning",
"ignore:unclosed <ssl.SSLSocket:ResourceWarning",
"ignore:datetime.datetime.utc:DeprecationWarning",
"ignore:GridOut property 'contentType' is deprecated and will be removed in PyMongo 5.0:DeprecationWarning",
"ignore:GridIn property 'contentType' is deprecated and will be removed in PyMongo 5.0:DeprecationWarning",
"ignore:GridOut property 'aliases' is deprecated and will be removed in PyMongo 5.0:DeprecationWarning",
# From older versions aiohttp.
"ignore:\"@coroutine\" decorator is deprecated since Python 3.8:DeprecationWarning",
"ignore:The loop argument is deprecated since Python 3.8:DeprecationWarning"

View File

@ -97,6 +97,10 @@ class AsyncIOTestCase(AssertLogsMixin, unittest.TestCase):
self.collection = self.db.test_collection
self.loop.run_until_complete(self.collection.drop())
# Workaround for https://github.com/pytest-dev/pytest/issues/12263.
def runTest(self):
pass
def get_client_kwargs(self, set_loop=True, **kwargs):
if set_loop:
kwargs.setdefault("io_loop", self.loop)

View File

@ -122,11 +122,13 @@ class AIOHTTPGridFSHandlerTestBase(AsyncIOTestCase):
async def stop(self):
# aiohttp.rtfd.io/en/stable/web.html#aiohttp-web-graceful-shutdown
self.srv.close()
await self.srv.wait_closed()
await self.app.shutdown()
await self.app_handler.shutdown(timeout=1)
await self.app.cleanup()
if self.srv is not None:
self.srv.close()
await self.srv.wait_closed()
if self.app is not None:
await self.app.shutdown()
await self.app_handler.shutdown(timeout=1)
await self.app.cleanup()
class AIOHTTPGridFSHandlerTest(AIOHTTPGridFSHandlerTestBase):

View File

@ -66,6 +66,10 @@ class MotorTest(testing.AsyncTestCase):
await self.collection.delete_many({})
await self.collection.insert_many([{"_id": i} for i in range(200)])
# Workaround for https://github.com/pytest-dev/pytest/issues/12263.
def runTest(self):
pass
make_test_data.__test__ = False
async def set_fail_point(self, client, command_args):

View File

@ -23,7 +23,7 @@ import unittest
from test.test_environment import CA_PEM, CLIENT_PEM, env
import gridfs
from tornado.testing import AsyncHTTPTestCase
from tornado import testing
from tornado.web import Application
import motor
@ -33,7 +33,7 @@ from motor.motor_gridfs import _hash_gridout
# We're using Tornado's AsyncHTTPTestCase instead of our own MotorTestCase for
# the convenience of self.fetch().
class GridFSHandlerTestBase(AsyncHTTPTestCase):
class GridFSHandlerTestBase(testing.AsyncHTTPTestCase):
def setUp(self):
super().setUp()
@ -73,6 +73,10 @@ class GridFSHandlerTestBase(AsyncHTTPTestCase):
self.fs.delete(self.file_id)
super().tearDown()
# Workaround for https://github.com/pytest-dev/pytest/issues/12263.
def runTest(self):
pass
def get_app(self):
return Application([("/(.+)", motor.web.GridFSHandler, {"database": self.motor_db()})])
@ -80,9 +84,9 @@ class GridFSHandlerTestBase(AsyncHTTPTestCase):
# A stop() method more permissive about the number of its positional
# arguments than AsyncHTTPTestCase.stop
if len(args) == 1:
AsyncHTTPTestCase.stop(self, args[0], **kwargs)
testing.AsyncHTTPTestCase.stop(self, args[0], **kwargs)
else:
AsyncHTTPTestCase.stop(self, args, **kwargs)
testing.AsyncHTTPTestCase.stop(self, args, **kwargs)
def parse_date(self, d):
date_tuple = email.utils.parsedate(d)