diff --git a/mako/util.py b/mako/util.py index 01081097d757f6fff6647f97562c85fa5509de3c..48e3a23a1b92f8c652435b80d76e6e1db778cc80 100644 --- a/mako/util.py +++ b/mako/util.py @@ -11,15 +11,10 @@ import os from mako import compat import operator -def function_named(fn, name): - """Return a function with a given __name__. - - Will assign to __name__ and return the original function if possible on - the Python implementation, otherwise a new function will be constructed. - - """ - fn.__name__ = name - return fn +def update_wrapper(decorated, fn): + decorated.__wrapped__ = fn + decorated.__name__ = fn.__name__ + return decorated class PluginLoader(object): diff --git a/setup.cfg b/setup.cfg index c933a4d31675e54a2e6be5b281d804157daace2e..6a03440240a1b3cd6d8b736df451ad7b8d8b8608 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,6 +5,11 @@ tag_build = dev [wheel] universal = 1 +[pytest] +addopts= --tb native -v -r fxX +python_files=test/*test_*.py + + [upload] sign = 1 identity = C4DAFEE1 diff --git a/test/__init__.py b/test/__init__.py index f114f648b7b0a05f888e58bd1feebf654162b583..64dde8e8df25f35eb96fcc69a53ba079c018eb59 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -2,7 +2,7 @@ from mako.template import Template import unittest import os from mako.compat import py3k, py26, py25 -from mako.util import function_named +from mako.util import update_wrapper import re from mako.cache import CacheImpl, register_plugin from nose import SkipTest @@ -93,7 +93,7 @@ def skip_if(predicate, reason=None): raise SkipTest(msg) else: return fn(*args, **kw) - return function_named(maybe, fn_name) + return update_wrapper(maybe, fn) return decorate def requires_python_3(fn): @@ -124,7 +124,7 @@ def requires_no_pygments_exceptions(fn): return fn(*arg, **kw) finally: exceptions._install_highlighting() - return function_named(go, fn.__name__) + return update_wrapper(go, fn) class PlainCacheImpl(CacheImpl): """Simple memory cache impl so that tests which