Skip to content

Commit

Permalink
Merge pull request #241 from iamibi/remove-pkg-resource-uses
Browse files Browse the repository at this point in the history
replaced pkg_resources with packaging module
  • Loading branch information
pnuckowski authored Aug 31, 2023
2 parents 56b8433 + 229f663 commit b444d72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions aioresponses/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
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):
from re import _pattern_type as Pattern
else:
from re import Pattern

AIOHTTP_VERSION = parse_version(aiohttp_version)
AIOHTTP_VERSION = Version(aiohttp_version)


def stream_reader_factory( # noqa
Expand Down
8 changes: 5 additions & 3 deletions tests/test_aioresponses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -31,6 +31,8 @@
from .base import fail_on, skipIf, AsyncTestCase


MINIMUM_AIOHTTP_VERSION = Version('3.4.0')

@ddt
class AIOResponsesTestCase(AsyncTestCase):

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b444d72

Please sign in to comment.