Skip to content

Commit

Permalink
fix: use 'six.wraps' vs. 'functools.wraps' (#37)
Browse files Browse the repository at this point in the history
'six.wraps' preserves metdata better under Python 2.7, which makes
stuff like pytest fixture injection work with plain functions.

Closes #36.
  • Loading branch information
tseaver committed Jun 29, 2021
1 parent 10b6611 commit 701c3a4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test_utils/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import time
from functools import wraps

import six

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 701c3a4

Please sign in to comment.