From 229f6635cc47983c697f50ba551d910812545df4 Mon Sep 17 00:00:00 2001 From: Ibrahim <8592115+iamibi@users.noreply.github.com> Date: Tue, 20 Jun 2023 08:39:26 -0400 Subject: [PATCH] replaced pkg_resources with packaging module --- aioresponses/compat.py | 4 ++-- tests/test_aioresponses.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/aioresponses/compat.py b/aioresponses/compat.py index a1462c1..aa8771d 100644 --- a/aioresponses/compat.py +++ b/aioresponses/compat.py @@ -7,7 +7,7 @@ from aiohttp import __version__ as aiohttp_version, StreamReader from aiohttp.client_proto import ResponseHandler from multidict import MultiDict -from pkg_resources import parse_version +from packaging.version import Version from yarl import URL if sys.version_info < (3, 7): @@ -15,7 +15,7 @@ else: from re import Pattern -AIOHTTP_VERSION = parse_version(aiohttp_version) +AIOHTTP_VERSION = Version(aiohttp_version) def stream_reader_factory( # noqa diff --git a/tests/test_aioresponses.py b/tests/test_aioresponses.py index be8357c..23d3b46 100644 --- a/tests/test_aioresponses.py +++ b/tests/test_aioresponses.py @@ -11,7 +11,7 @@ from aiohttp.client import ClientSession from aiohttp.client_reqrep import ClientResponse from ddt import ddt, data -from pkg_resources import parse_version +from packaging.version import Version try: from aiohttp.errors import ( @@ -31,6 +31,8 @@ from .base import fail_on, skipIf, AsyncTestCase +MINIMUM_AIOHTTP_VERSION = Version('3.4.0') + @ddt class AIOResponsesTestCase(AsyncTestCase): @@ -118,7 +120,7 @@ async def test_raise_for_status(self, m): self.assertEqual(cm.exception.message, http.RESPONSES[400][0]) @aioresponses() - @skipIf(condition=AIOHTTP_VERSION < parse_version('3.4.0'), + @skipIf(condition=AIOHTTP_VERSION < MINIMUM_AIOHTTP_VERSION, reason='aiohttp<3.4.0 does not support raise_for_status ' 'arguments for requests') async def test_request_raise_for_status(self, m): @@ -664,7 +666,7 @@ async def test_raise_for_status(self, m): self.assertEqual(cm.exception.message, http.RESPONSES[400][0]) @aioresponses() - @skipIf(condition=AIOHTTP_VERSION < parse_version('3.4.0'), + @skipIf(condition=AIOHTTP_VERSION < MINIMUM_AIOHTTP_VERSION, reason='aiohttp<3.4.0 does not support raise_for_status ' 'arguments for requests') async def test_do_not_raise_for_status(self, m):