3

My pytest.ini currently looks like this:

[pytest]
addopts = --doctest-modules --cov=. --cov-report html --pep8 --flakes
doctest_encoding = utf-8

So I already test for PEP8. But I would also like to test the docstrings for numpydoc format:

  • Are all parameters named in the correct order?
  • If there is a return statement, is there also Returns in the docstring?
  • ...

Is this possible

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
  • I just found something for pylint: https://stackoverflow.com/q/42123798/562769 – Martin Thoma Aug 14 '17 at 11:35
  • 2
    [pydocstyle](https://github.com/PyCQA/pydocstyle/pull/226) has implemented the checks using `convention=numpy`. – phd Aug 14 '17 at 18:49
  • @phd If you tell me how to add it to my `pytest.ini` this would be the answer to the question. – Martin Thoma Aug 14 '17 at 19:29
  • Add `pydocstyle` to your `requirements-dev.txt`, install it and run the command `pydocstyle $TOPLEVEL_MODULE` where `$TOPLEVEL_MODULE` is the top-level module of your project. I doubt `pydocstyle` can be integrated with `pytest`. – phd Aug 14 '17 at 19:53
  • This is a case where [tox shines](https://stackoverflow.com/questions/35239628/how-to-run-py-test-and-linters-in-python-setup-py-test). – theY4Kman Aug 18 '17 at 19:13

0 Answers0