From 44a4545273c99bc7e297fbed9236ad94aa720b91 2008-08-24 06:50:21 From: Fernando Perez Date: 2008-08-24 06:50:21 Subject: [PATCH] Fix error in test decorator. --- diff --git a/IPython/testing/decorators.py b/IPython/testing/decorators.py index 8d726de..78b6840 100644 --- a/IPython/testing/decorators.py +++ b/IPython/testing/decorators.py @@ -120,8 +120,7 @@ skip_doctest = make_label_dec('skip_doctest', omit from testing, while preserving the docstring for introspection, help, etc.""") - -def skip(func,msg=''): +def skip(msg=''): """Decorator - mark a test function for skipping from test suite. :Parameters: @@ -134,13 +133,15 @@ def skip(func,msg=''): """ import nose - - def wrapper(*a,**k): - if msg: out = '\n'+msg - else: out = '' - raise nose.SkipTest("Skipping test for function: %s%s" % - (func.__name__,out)) - - return apply_wrapper(wrapper,func) + def inner(func): + + def wrapper(*a,**k): + if msg: out = '\n'+msg + else: out = '' + raise nose.SkipTest("Skipping test for function: %s%s" % + (func.__name__,out)) + + return apply_wrapper(wrapper,func) + return inner diff --git a/IPython/testing/plugin/test_refs.py b/IPython/testing/plugin/test_refs.py index 2c6e88b..fc7e6f0 100644 --- a/IPython/testing/plugin/test_refs.py +++ b/IPython/testing/plugin/test_refs.py @@ -45,6 +45,11 @@ def test_deliberately_broken(): """A deliberately broken test - we want to skip this one.""" 1/0 +@dec.skip('foo') +def test_deliberately_broken2(): + """Another deliberately broken test - we want to skip this one.""" + 1/0 + # Verify that we can correctly skip the doctest for a function at will, but # that the docstring itself is NOT destroyed by the decorator.