Fix failing tests
diff --git a/parameterized/parameterized.py b/parameterized/parameterized.py index 0138334..4a51aad 100644 --- a/parameterized/parameterized.py +++ b/parameterized/parameterized.py
@@ -24,7 +24,6 @@ # future code can be written to assume Python 3. PY3 = sys.version_info[0] == 3 PY2 = sys.version_info[0] == 2 -PY35_OR_NEWER = PY3 and sys.version_info.minor >= 5 if PY3: @@ -86,9 +85,7 @@ return dummy_func if hasattr(func, 'patchings'): - is_original_async = False - if PY35_OR_NEWER: - is_original_async = inspect.iscoroutinefunction(func) + is_original_async = inspect.iscoroutinefunction(func) func = dummy_wrapper(func) tmp_patchings = func.patchings delattr(func, 'patchings') @@ -554,13 +551,20 @@ delete_patches_if_need(f) f.__test__ = False + return parameterized_expand_wrapper @classmethod def param_as_standalone_func(cls, p, func, name): - @wraps(func) - def standalone_func(*a): - return func(*(a + p.args), **p.kwargs) + if inspect.iscoroutinefunction(func): + @wraps(func) + async def standalone_func(*a): + return await func(*(a + p.args), **p.kwargs) + else: + @wraps(func) + def standalone_func(*a): + return func(*(a + p.args), **p.kwargs) + standalone_func.__name__ = name # place_as is used by py.test to determine what source file should be
diff --git a/parameterized/test.py b/parameterized/test.py index f380f90..046f83d 100644 --- a/parameterized/test.py +++ b/parameterized/test.py
@@ -565,12 +565,19 @@ class TestAsyncParameterizedExpandWithNoMockPatchForClass(IsolatedAsyncioTestCase): expect([ + "test_one_async_function('foo1')", + "test_one_async_function('foo0')", + "test_one_async_function(42)", "test_one_async_function_patch_decorator('foo1', 'umask')", "test_one_async_function_patch_decorator('foo0', 'umask')", "test_one_async_function_patch_decorator(42, 'umask')", ]) @parameterized.expand([(42,), "foo0", param("foo1")]) + async def test_one_async_function(self, foo): + missing_tests.remove("test_one_async_function(%r)" % (foo, )) + + @parameterized.expand([(42,), "foo0", param("foo1")]) @mock.patch("os.umask") async def test_one_async_function_patch_decorator(self, foo, mock_umask): missing_tests.remove("test_one_async_function_patch_decorator(%r, %r)" %