Search code examples
pylint

Pylint and unittest


I have a python project that is using pylint and unittest. Unittest has me using methods called setUp() which pylint doesn't like. Specifically:

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

How can I get pylint to allow setUp as a method name? I don't see a configuration item called "allowed method names" for example. I'd rather not use # pylint: disable=C0103 all over as there are a lot of setUp methods in my code.


Solution

  • 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))$