numpy.testing.decorate_methods

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

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

给定的decorator应用于 cls 与正则表达式匹配的 testmatch (testmatch.search(methodname) )忽略私有方法,即以下划线开头的方法。

参数
cls

要修饰其方法的类。

decorator功能

应用于方法的修饰器

testmatch编译的regexp或str,可选

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