numpy.testing.decorate_methods#

testing.decorate_methods(cls, decorator, testmatch=None)[源代码]#

将装饰器应用于类中所有与正则表达式匹配的方法。

给定的装饰器将应用于 cls 中所有与正则表达式 testmatch (testmatch.search(methodname)) 匹配的公共方法。私有方法(即以_开头的方法)将被忽略。

参数:
clsclass

要装饰方法的类。

decoratorfunction

要应用于方法的装饰器

testmatchcompiled regexp or str, optional

正则表达式。默认值为 None,在这种情况下,将使用 nose 的默认值(re.compile(r'(?:^|[\b_\.%s-])[Tt]est' % os.sep))。如果 testmatch 是一个字符串,它首先会被编译成一个正则表达式。