Skip to content
Snippets Groups Projects
Commit 3a7c3a61 authored by Vermaat's avatar Vermaat
Browse files

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
parent be4bdc68
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,7 @@ import math ...@@ -25,6 +25,7 @@ import math
import time import time
import inspect import inspect
from itertools import izip_longest from itertools import izip_longest
from functools import wraps
import Bio.Seq import Bio.Seq
from Bio.Alphabet import IUPAC from Bio.Alphabet import IUPAC
...@@ -804,6 +805,7 @@ def slow(f): ...@@ -804,6 +805,7 @@ def slow(f):
@todo: I don't think this actually belongs here (a separate util module @todo: I don't think this actually belongs here (a separate util module
for the unit tests?). for the unit tests?).
""" """
@wraps(f)
def slow_f(*args, **kwargs): def slow_f(*args, **kwargs):
if 'MUTALYZER_QUICK_TEST' in os.environ \ if 'MUTALYZER_QUICK_TEST' in os.environ \
and os.environ['MUTALYZER_QUICK_TEST'] == '1': and os.environ['MUTALYZER_QUICK_TEST'] == '1':
...@@ -823,6 +825,7 @@ def skip(f): ...@@ -823,6 +825,7 @@ def skip(f):
@todo: I don't think this actually belongs here (a separate util module @todo: I don't think this actually belongs here (a separate util module
for the unit tests?). for the unit tests?).
""" """
@wraps(f)
def disabled_f(*args, **kwargs): def disabled_f(*args, **kwargs):
return return
return disabled_f return disabled_f
...@@ -842,6 +845,7 @@ def singleton(cls): ...@@ -842,6 +845,7 @@ def singleton(cls):
[1] http://www.python.org/dev/peps/pep-0318/#examples [1] http://www.python.org/dev/peps/pep-0318/#examples
""" """
instances = {} instances = {}
@wraps(cls)
def getinstance(): def getinstance():
if cls not in instances: if cls not in instances:
instances[cls] = cls() instances[cls] = cls()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment