1

I have a helper function called _prepend_order in a Python module. I would like to unit test it. I also want my unit test (test_extract_users.py) to pass our linter, pylint. We are trying to avoid use of directives like #pylint: disable=protected-access (here, and docs here) in favour of agreeing changes to our top-level .pylintrc file.

Is it possible to configure pylint via the .pylintrc file so that protected member access warnings are disabled in all unit tests (and not disabled elsewhere)?

(N.B. There is an open issue from August 2015, 618: Add different configuration for different sub directories, which would work as I could put my unit tests in a 'tests' sub-directory. But unfortunately that issue is still open in August 2019 and so I suspect that the answer to this Stack Overflow question is "No, it is not possible".)

dumbledad
  • 16,305
  • 23
  • 120
  • 273

1 Answers1

1

I'm not sure there is a configuration option available for something like this. It's ugly, but you could use a separate .pylintrc file for linting your tests by utilizing the --rcfile argument to pylint.

In this case, I think I'd just go with using the directive.

Nate Dellinger
  • 740
  • 5
  • 14