8

我有一个使用 pylint 和 unittest 的 python 项目。Unittest 让我使用 pylint 不喜欢的名为 setUp() 的方法。具体来说:

C0103: 57,4:<class>.setUp: Invalid name "setUp" for type method (should match [a-z_][a-z0-9_]{2,30}$)

如何让 pylint 允许 setUp 作为方法名称?例如,我没有看到名为“允许的方法名称”的配置项。我宁愿不要# pylint: disable=C0103全部使用,因为我的代码中有很多 setUp 方法。

4

1 回答 1

13

change the method-rgx setting in your configuration file (it's in the BASIC section). Something like this should do the trick:

method-rgx=(([a-z_][a-z0-9_]{2,30})|(setUp)|(tearDown))$
于 2012-11-05T16:42:52.167 回答