I have a pretty large test suite and I decorated some of the test_* functions. Now I can\'t call them by ./test.py MySqlTestCase.test_foo_double
, python3.2 comp
Based on this post:
You can do it this way:
def decorator(test):
def wrapper(self):
# do something interesting
test(self)
# do something interesting
wrapper.__name__ = test.__name__
return wrapper
This solution has two advantages over method with @functools.wrap
:
Thanks to the second feature of this solution, it is possible to create decorators for many tests.