From 3a7c3a611cd6c81fb8aac7010990b1b18ed39330 Mon Sep 17 00:00:00 2001
From: Martijn Vermaat <martijn@vermaat.name>
Date: Fri, 5 Oct 2012 13:40:20 +0000
Subject: [PATCH] Use functools.wraps in decorators

This makes sure docstring and name are inherited from the decorated
definition. Fixes decorated unit tests, which previously where skipped
since their name did not start with test_ after decorating.


git-svn-id: https://humgenprojects.lumc.nl/svn/mutalyzer/trunk@619 eb6bd6ab-9ccd-42b9-aceb-e2899b4a52f1
---
 mutalyzer/util.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/mutalyzer/util.py b/mutalyzer/util.py
index 95109489..8b555f9c 100644
--- a/mutalyzer/util.py
+++ b/mutalyzer/util.py
@@ -25,6 +25,7 @@ import math
 import time
 import inspect
 from itertools import izip_longest
+from functools import wraps
 
 import Bio.Seq
 from Bio.Alphabet import IUPAC
@@ -804,6 +805,7 @@ def slow(f):
     @todo: I don't think this actually belongs here (a separate util module
       for the unit tests?).
     """
+    @wraps(f)
     def slow_f(*args, **kwargs):
         if 'MUTALYZER_QUICK_TEST' in os.environ \
                and os.environ['MUTALYZER_QUICK_TEST'] == '1':
@@ -823,6 +825,7 @@ def skip(f):
     @todo: I don't think this actually belongs here (a separate util module
       for the unit tests?).
     """
+    @wraps(f)
     def disabled_f(*args, **kwargs):
         return
     return disabled_f
@@ -842,6 +845,7 @@ def singleton(cls):
     [1] http://www.python.org/dev/peps/pep-0318/#examples
     """
     instances = {}
+    @wraps(cls)
     def getinstance():
         if cls not in instances:
             instances[cls] = cls()
-- 
GitLab