From c2373cede978a62eb3c142c5ca4bb1a02a32b3ad Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 13 Apr 2014 13:47:25 -0400 Subject: - add py.test settings - fix this update_wrapper thing so tests are reported nicely --- mako/util.py | 13 ++++--------- setup.cfg | 5 +++++ test/__init__.py | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mako/util.py b/mako/util.py index 0108109..48e3a23 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 c933a4d..6a03440 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 f114f64..64dde8e 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 -- cgit v1.2.3