Skip to content

Commit

Permalink
fix: added condition on py3.8 while supporting ClientSession.base_url
Browse files Browse the repository at this point in the history
  • Loading branch information
pnuckowski committed Dec 11, 2024
1 parent 36c0329 commit d4eabd3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions aioresponses/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
)
from aiohttp.helpers import TimerNoop
from multidict import CIMultiDict, CIMultiDictProxy
from packaging.version import Version

from .compat import (
URL,
Pattern,
stream_reader_factory,
merge_params,
normalize_url,
RequestInfo,
RequestInfo, AIOHTTP_VERSION,
)


Expand Down Expand Up @@ -500,13 +501,15 @@ async def _request_mock(self, orig_self: ClientSession,
if orig_self.closed:
raise RuntimeError('Session is closed')

# Join url with ClientSession._base_url
url = orig_self._build_url(url)
url_origin = str(url)

# Combine ClientSession headers with passed headers
if orig_self.headers:
kwargs["headers"] = orig_self._prepare_headers(kwargs.get("headers"))
if AIOHTTP_VERSION >= Version('3.8.0'):
# Join url with ClientSession._base_url
url = orig_self._build_url(url)
url_origin = str(url)
# Combine ClientSession headers with passed headers
if orig_self.headers:
kwargs["headers"] = orig_self._prepare_headers(kwargs.get("headers"))

Check failure on line 510 in aioresponses/core.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] aioresponses/core.py#L510 <501>

line too long (85 > 79 characters)
Raw output
./aioresponses/core.py:510:80: E501 line too long (85 > 79 characters)
else:
url_origin = url

url = normalize_url(merge_params(url, kwargs.get('params')))
url_str = str(url)
Expand Down

0 comments on commit d4eabd3

Please sign in to comment.