numpy.testing.decorate_methods#

testing.decorate_methods(cls, decorator, testmatch=None)[source]#

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

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

参数:
cls

要装饰其方法的类。

decorator函数

要应用于方法的装饰器

testmatch编译后的正则表达式或字符串,可选

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