Skip to content

Commit

Permalink
Update function unittest_run_loop to provide *args, **kwargs. Useful …
Browse files Browse the repository at this point in the history
…with other decorators, for example @patch.
  • Loading branch information
y_temusheva committed Apr 10, 2017
1 parent f64e610 commit fc633b6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
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

- Updating function `unittest_run_loop` to provide \*args, \*\*kwargs. Useful with other decorators, for example @patch. #1804


2.0.6 (2017-04-04)
------------------
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,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

0 comments on commit fc633b6

Please sign in to comment.