【发布时间】:2010-02-10 14:51:10
【问题描述】:
我已将装饰器@login_testuser 应用于方法test_1():
class TestCase(object):
@login_testuser
def test_1(self):
print "test_1()"
有没有一种方法可以将@login_testuser 应用于以"test_" 为前缀的类的每个 方法?
换句话说,装饰器将应用于下面的test_1()、test_2() 方法,但不适用于setUp()。
class TestCase(object):
def setUp(self):
pass
def test_1(self):
print "test_1()"
def test_2(self):
print "test_2()"
【问题讨论】: