numpy.testing.decorate_methods#
- testing.decorate_methods(cls, decorator, testmatch=None)[源代码]#
将装饰器应用于类中与正则表达式匹配的所有方法.
给定的装饰器应用于 cls 的所有公共方法,这些方法与正则表达式 testmatch 匹配 (
testmatch.search(methodname)).私有方法,即以下划线开头的方法,将被忽略.- 参数:
- clsclass
要装饰其方法的类.
- decoratorfunction
应用于方法的装饰器
- testmatch已编译的 regexp 或 str, 可选
正则表达式.默认值为 None,在这种情况下,使用 nose 默认值 (
re.compile(r'(?:^|[\b_\.%s-])[Tt]est' % os.sep)).如果 testmatch 是一个字符串,它首先被编译成一个正则表达式.