Skip to content

Commit

Permalink
run_app: make print=None disable printing (#2260)
Browse files Browse the repository at this point in the history
  • Loading branch information
seirl authored and asvetlov committed Sep 12, 2017
1 parent c6c04f2 commit 8a85651
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Andrew Leech
Andrew Lytvyn
Andrew Svetlov
Andrii Soldatenko
Antoine Pietri
Anton Kasyanov
Arthur Darcet
Ben Bader
Expand Down
5 changes: 3 additions & 2 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,9 @@ def run_app(app, *, host=None, port=None, path=None, sock=None,
pass

try:
print("======== Running on {} ========\n"
"(Press CTRL+C to quit)".format(', '.join(uris)))
if print:
print("======== Running on {} ========\n"
"(Press CTRL+C to quit)".format(', '.join(uris)))
loop.run_forever()
except (GracefulExit, KeyboardInterrupt): # pragma: no cover
pass
Expand Down
1 change: 1 addition & 0 deletions changes/2260.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run_app: Make print=None disable printing
3 changes: 2 additions & 1 deletion docs/web_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2400,7 +2400,8 @@ Utilities
``None`` for HTTP connection.

:param print: a callable compatible with :func:`print`. May be used
to override STDOUT output or suppress it.
to override STDOUT output or suppress it. Passing `None`
disables output.

:param int backlog: the number of unaccepted connections that the
system will allow before refusing new
Expand Down
2 changes: 1 addition & 1 deletion tests/test_run_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def test_run_app_mixed_bindings(mocker, run_app_kwargs, expected_server_calls,
loop = mocker.MagicMock()
mocker.patch('asyncio.gather')

web.run_app(app, loop=loop, print=lambda *args: None, **run_app_kwargs)
web.run_app(app, loop=loop, print=None, **run_app_kwargs)

assert loop.create_unix_server.mock_calls == expected_unix_server_calls
assert loop.create_server.mock_calls == expected_server_calls
Expand Down

0 comments on commit 8a85651

Please sign in to comment.