Skip to content

Commit

Permalink
switch noop from function to class (#4322)
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomsForPeace authored and asvetlov committed Nov 9, 2019
1 parent 56177c0 commit 2ca3c38
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGES/4282.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove warning messages from noop.
9 changes: 4 additions & 5 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Awaitable,
Callable,
Dict,
Generator,
Iterable,
Iterator,
List,
Expand Down Expand Up @@ -100,12 +101,10 @@ def all_tasks(
coroutines = asyncio.coroutines
old_debug = coroutines._DEBUG # type: ignore

# prevent "coroutine noop was never awaited" warning.
coroutines._DEBUG = False # type: ignore


async def noop(*args: Any, **kwargs: Any) -> None:
return
class noop:
def __await__(self) -> Generator[None, None, None]:
yield


coroutines._DEBUG = old_debug # type: ignore
Expand Down
15 changes: 0 additions & 15 deletions tests/test_web_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,21 +255,6 @@ async def test_bad_method(srv, buf) -> None:
assert buf.startswith(b'HTTP/1.0 400 Bad Request\r\n')


async def test_data_received_error(srv, buf) -> None:
transport = srv.transport
srv._request_parser = mock.Mock()
srv._request_parser.feed_data.side_effect = TypeError

srv.data_received(
b'!@#$ / HTTP/1.0\r\n'
b'Host: example.com\r\n\r\n')

await asyncio.sleep(0)
assert buf.startswith(b'HTTP/1.0 500 Internal Server Error\r\n')
assert transport.close.called
assert srv._error_handler is None


async def test_line_too_long(srv, buf) -> None:
srv.data_received(b''.join([b'a' for _ in range(10000)]) + b'\r\n\r\n')

Expand Down

0 comments on commit 2ca3c38

Please sign in to comment.