From 2c2ed3479c50b9f9a63ba1895cd876729db5c959 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 25 Jun 2021 13:58:36 -0400 Subject: [PATCH] fix: use 'six.wraps' vs. 'functools.wraps' 'six.wraps' preserves metdata better under Python 2.7, which makes stuff like pytest fixture injection work with plain functions. Closes #36. --- test_utils/retry.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test_utils/retry.py b/test_utils/retry.py index c11e67a..9880658 100644 --- a/test_utils/retry.py +++ b/test_utils/retry.py @@ -13,7 +13,6 @@ # limitations under the License. import time -from functools import wraps import six @@ -94,7 +93,7 @@ def __init__( self.error_predicate = error_predicate def __call__(self, to_wrap): - @wraps(to_wrap) + @six.wraps(to_wrap) def wrapped_function(*args, **kwargs): tries = 0 while tries < self.max_tries: @@ -152,7 +151,7 @@ def __init__( self.result_predicate = result_predicate def __call__(self, to_wrap): - @wraps(to_wrap) + @six.wraps(to_wrap) def wrapped_function(*args, **kwargs): tries = 0 while tries < self.max_tries: @@ -209,7 +208,7 @@ def __init__( def __call__(self, to_wrap): instance = to_wrap.__self__ # only instance methods allowed - @wraps(to_wrap) + @six.wraps(to_wrap) def wrapped_function(*args, **kwargs): tries = 0 while tries < self.max_tries: