From b578122363a960d4c7a439836d5ef70da1e1f00b Mon Sep 17 00:00:00 2001 From: Jib Date: Tue, 30 Jan 2024 12:20:09 -0500 Subject: [PATCH] MOTOR-1218: Upgrade to require aiohttp >=3.8 and avoid 3.8.6 (#251) --- pyproject.toml | 3 ++- test/asyncio_tests/test_aiohttp_gridfs.py | 2 +- test/test_environment.py | 8 +++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c34a6126..8c71017b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ srv = [ "pymongo[srv]>=4.5,<5", ] test = [ - "pytest>=7", "mockupdb", "tornado>=5", "aiohttp<3.8.6", "motor[encryption]" + "pytest>=7", "mockupdb", "tornado>=5", "aiohttp>=3.8,!=3.8.6", "motor[encryption]" ] zstd = [ "pymongo[zstd]>=4.5,<5", @@ -94,6 +94,7 @@ warn_redundant_casts = true warn_unreachable = true disable_error_code = ["type-arg"] enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] +exclude = ["aiohttp"] # Remove when drop support for 3.7 [tool.pytest.ini_options] minversion = "7" diff --git a/test/asyncio_tests/test_aiohttp_gridfs.py b/test/asyncio_tests/test_aiohttp_gridfs.py index 57ddac28..6bcb8cf2 100644 --- a/test/asyncio_tests/test_aiohttp_gridfs.py +++ b/test/asyncio_tests/test_aiohttp_gridfs.py @@ -221,7 +221,7 @@ async def test_content_type(self): response = await method("/fs/" + filename) self.assertEqual(200, response.status) # mimetypes are platform-defined, be fuzzy - self.assertIn(expected_type, response.headers["Content-Type"].lower()) + self.assertIn(expected_type, response.content_type) @asyncio_test async def test_post(self): diff --git a/test/test_environment.py b/test/test_environment.py index 9bdbd1c7..7127a1dc 100644 --- a/test/test_environment.py +++ b/test/test_environment.py @@ -20,6 +20,7 @@ from functools import wraps from test.utils import create_user from test.version import Version +from typing import TYPE_CHECKING from unittest import SkipTest import pymongo.errors @@ -50,7 +51,12 @@ HAVE_AIOHTTP = True try: - import aiohttp + # Remove when we drop support for 3.7 + if TYPE_CHECKING: + HAVE_AIOHTTP = False + aiohttp = None + else: + import aiohttp except ImportError: HAVE_AIOHTTP = False aiohttp = None