Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced pkg_resources with packaging module #241

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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