The PEP-8 document says:
sometimes style guide recommendations just aren't applicable
Here, the recommendation in question is:
Write docstrings for all public modules, functions, classes, and methods. Docstrings are not necessary for non-public methods, but you should have a comment that describes what the method does.
I'd argue that tests are not public modules in the sense of this recommendation, even though a test files technically is a module that could be imported and its contents are technically public. This just isn't the case.
The intention for using docstrings is that you know how to call the function. But test functions are never called directly. There's a secondary task of documenting the contents of the function (although normal comments also do the job). However, test functions often have very long and self-documenting names, so this is less of a concern.
Keeping tests somewhat tidy is legitimately important, so it can make sense to run flake8 or other linters over the test code as well. But since testing is a different context from normal code, some values are different. E.g. it is important that tests are independent, less important that tests are DRY. And whereas unused functions indicate a bug in normal code, this is normal in test code.
I would advise one of the following approaches:
- exclude tests from linting, e.g. via a configuration file or with
# flake8: noqa comments. However, this is a fairly drastic approach.
- disable just this lint within the file, e.g. with
# noqa: D103 comments. However, I'm not sure if flake8 allows you to disable a lint for the entire file, or just for the current line.