summaryrefslogtreecommitdiff
path: root/git/test/lib
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-10-02 22:39:27 +0200
committerGitHub <noreply@github.com>2016-10-02 22:39:27 +0200
commitfd8537b23ce85be6f9dacb7806e791b7f902a206 (patch)
treeec46b9f3844cc71c9e47546bf991640e0226c33d /git/test/lib
parentdf5c1cb715664fd7a98160844572cc473cb6b87c (diff)
parent51f4a1407ef12405e16f643f5f9d2002b4b52ab9 (diff)
downloadgitpython-fd8537b23ce85be6f9dacb7806e791b7f902a206.tar.gz
Merge pull request #523 from yarikoptic/enh-wraps
RF: use @functools.wraps within decorators instead of manual __name__ reassignment
Diffstat (limited to 'git/test/lib')
-rw-r--r--git/test/lib/helper.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py
index a85ac2fd..e55a23df 100644
--- a/git/test/lib/helper.py
+++ b/git/test/lib/helper.py
@@ -12,6 +12,8 @@ import tempfile
import io
import logging
+from functools import wraps
+
from git import Repo, Remote, GitCommandError, Git
from git.util import rmtree
from git.compat import string_types, is_win
@@ -86,6 +88,7 @@ def with_rw_directory(func):
"""Create a temporary directory which can be written to, remove it if the
test succeeds, but leave it otherwise to aid additional debugging"""
+ @wraps(func)
def wrapper(self):
path = tempfile.mktemp(prefix=func.__name__)
os.mkdir(path)
@@ -122,6 +125,7 @@ def with_rw_repo(working_tree_ref, bare=False):
assert isinstance(working_tree_ref, string_types), "Decorator requires ref name for working tree checkout"
def argument_passer(func):
+ @wraps(func)
def repo_creator(self):
prefix = 'non_'
if bare:
@@ -155,7 +159,6 @@ def with_rw_repo(working_tree_ref, bare=False):
# END rm test repo if possible
# END cleanup
# END rw repo creator
- repo_creator.__name__ = func.__name__
return repo_creator
# END argument passer
return argument_passer
@@ -211,6 +214,7 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
def argument_passer(func):
+ @wraps(func)
def remote_repo_creator(self):
remote_repo_dir = _mktemp("remote_repo_%s" % func.__name__)
repo_dir = _mktemp("remote_clone_non_bare_repo")
@@ -319,10 +323,9 @@ def with_rw_and_rw_remote_repo(working_tree_ref):
gd.proc.wait()
# END cleanup
# END bare repo creator
- remote_repo_creator.__name__ = func.__name__
return remote_repo_creator
# END remote repo creator
- # END argument parsser
+ # END argument parser
return argument_passer