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

Update function unittest_run_loop to provide *args, **kwargs. Useful with other decorators, for example @patch #1803

Merged
merged 2 commits into from
Apr 11, 2017
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Changes

- Dropped "%O" in access logger #1673

- Added `args` and `kwargs` to `unittest_run_loop`. Useful with other decorators, for example `@patch`. #1803

- Added `iter_chunks` to response.content object. #1805


Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,4 @@ Yury Selivanov
Yusuke Tsutsumi
Марк Коренберг
Семён Марьясин
Julia Tsemusheva
6 changes: 3 additions & 3 deletions aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,17 @@ def _get_client(self, app):
return TestClient(self.app, loop=self.loop)


def unittest_run_loop(func):
def unittest_run_loop(func, *args, **kwargs):
"""A decorator dedicated to use with asynchronous methods of an
AioHTTPTestCase.

Handles executing an asynchronous function, using
the self.loop of the AioHTTPTestCase.
"""

@functools.wraps(func)
@functools.wraps(func, *args, **kwargs)
def new_func(self):
return self.loop.run_until_complete(func(self))
return self.loop.run_until_complete(func(self, *args, **kwargs))

return new_func

Expand Down
2 changes: 1 addition & 1 deletion tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def prop(self):
a.prop = 123


@pytest.mark.skipif(sys.version_info < (3, 5), reason='old python')
@pytest.mark.skipif(sys.version_info < (3, 5, 2), reason='old python')
def test_create_future_with_new_loop():
# We should use the new create_future() if it's available.
mock_loop = mock.Mock()
Expand Down