Skip to content

Commit

Permalink
Fix tests 3
Browse files Browse the repository at this point in the history
  • Loading branch information
alfred82santa committed Mar 3, 2021
1 parent e612e05 commit d1c213c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion service_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

try:
current_task = Task.current_task
except AttributeError:
except AttributeError: # pragma: no cover
from asyncio import current_task

from aiohttp.client import ClientSession
Expand Down
5 changes: 3 additions & 2 deletions service_client/formatters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from urllib.parse import urlencode
from http.server import BaseHTTPRequestHandler
from logging import Formatter, PercentStyle, StrFormatStyle, StringTemplateStyle
from urllib.parse import urlencode

_STYLES = {
'%': PercentStyle,
Expand Down Expand Up @@ -70,7 +70,8 @@ def formatMessage(self, record):
pass

try:
record.exception_repr = repr(record.exception)
record.exception_repr = "{type}('{message}')".format(type=type(record.exception).__name__,
message=str(record.exception))
except AttributeError:
pass

Expand Down
4 changes: 1 addition & 3 deletions service_client/mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from asyncio.futures import Future
from functools import wraps


from aiohttp import RequestInfo
from aiohttp.client_reqrep import ClientResponse
from aiohttp.helpers import TimerContext
Expand Down Expand Up @@ -194,7 +193,7 @@ def __init__(self, endpoint_desc, session, request_params,
async def __call__(self, *args, **kwargs):
try:
from asyncio import create_task
except IndexError:
except ImportError: # pragma: no cover
create_task = self.loop.create_task

args = list(args)
Expand All @@ -208,7 +207,6 @@ async def __call__(self, *args, **kwargs):
except KeyError:
url = args.pop()


self.method = method
self.url = url
self.args = args
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async def create_fake_response(method, url, *, session, headers=None, loop=None)

try:
from asyncio import create_task
except ImportError:
except ImportError: # pragma: no cover
create_task = loop.create_task

async def writer(*args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

try:
all_tasks = Task.all_tasks
except AttributeError:
except AttributeError: # pragma: no cover
from asyncio import all_tasks

from aiohttp.client import ClientSession
Expand Down
2 changes: 1 addition & 1 deletion tests/tests_service_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

try:
current_task = Task.current_task
except AttributeError:
except AttributeError: # pragma: no cover
from asyncio import current_task

from aiohttp import RequestInfo
Expand Down

0 comments on commit d1c213c

Please sign in to comment.