Wed Nov 1 15:02:07 2006

Ticket #101 (Closed: invalid)

Doesn't select decorated methods/functions


Priority: normal Reporter: guest
Severity: normal Assigned to: jpellerin
Component: nose:selector Status: closed
Version: 0.9 Resolution: invalid
Milestone: 0.9.2 Keywords:  

Description by guest:

If a function has a decoration nose will not pick it up for testing, it is of type 'function proxy' instead of 'function'.

This was tested on Debian testing with version 0.9.0-1

Test case:

def my_decor(func):
        return lambda: func()

def test_decor():
        assert False

@my_decor
def test_decor1():
        assert False

In the above test case we have two functions, one decorated and one not. Running it through nosetests shows only one detected function which fails while we expect two functions failing.

Running it in verbose mode will show that test_decor1 is not picked up for testing.

Changelog

Wed Nov 1 17:07:10 2006: Modified by jpellerin

  • milestone set to 0.9.2
  • status changed from new to assigned

Tue Dec 5 16:52:52 2006: Modified by jpellerin

  • resolution set to invalid
  • status changed from assigned to closed

This is the same issue as #105: when decorators don't preserve function details (like the function name), nose won't collect the decorated functions. There's no solution for this in nose itself, the solution is to write decorators that preserve all attributes of the decorated function. See nose.tools.make_decorator for an example, or if using python 2.5, use functools.wraps.