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

Support async functions under patch decorator #135

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion parameterized/parameterized.py
Expand Up @@ -21,6 +21,7 @@ class SkipTest(Exception):

PY3 = sys.version_info[0] == 3
PY2 = sys.version_info[0] == 2
PY35_OR_NEWER = PY3 and sys.version_info.minor >= 5


if PY3:
Expand Down Expand Up @@ -82,11 +83,17 @@ def dummy_func(*args, **kwargs):
return dummy_func

if hasattr(func, 'patchings'):
is_original_async = False
if PY35_OR_NEWER:
is_original_async = inspect.iscoroutinefunction(func)
func = dummy_wrapper(func)
tmp_patchings = func.patchings
delattr(func, 'patchings')
for patch_obj in tmp_patchings:
func = patch_obj.decorate_callable(func)
if is_original_async:
func = patch_obj.decorate_async_callable(func)
else:
func = patch_obj.decorate_callable(func)
return func


Expand Down