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

switch noop from function to class #4322

Merged
merged 5 commits into from
Nov 9, 2019
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
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