Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_docstyle.py 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Copyright (c) 2016-2017 Claudiu Popa <pcmanticore@gmail.com>
  2. # Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com>
  3. # Copyright (c) 2016 Luis Escobar <lescobar@vauxoo.com>
  4. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  5. # For details: https://github.com/PyCQA/pylint/blob/master/COPYING
  6. """Tests for the pylint checker in :mod:`pylint.extensions.check_docstring
  7. """
  8. import os.path as osp
  9. import pytest
  10. from pylint.extensions.docstyle import DocStringStyleChecker
  11. EXPECTED_MSGS = [
  12. 'First line empty in function docstring',
  13. 'First line empty in class docstring',
  14. 'First line empty in method docstring',
  15. 'Bad docstring quotes in method, expected """, given \'\'\'',
  16. 'Bad docstring quotes in method, expected """, given "',
  17. 'Bad docstring quotes in method, expected """, given \'',
  18. 'Bad docstring quotes in method, expected """, given \'',
  19. ]
  20. EXPECTED_SYMBOLS = [
  21. 'docstring-first-line-empty',
  22. 'docstring-first-line-empty',
  23. 'docstring-first-line-empty',
  24. 'bad-docstring-quotes',
  25. 'bad-docstring-quotes',
  26. 'bad-docstring-quotes',
  27. 'bad-docstring-quotes',
  28. ]
  29. @pytest.fixture(scope="module")
  30. def checker(checker):
  31. return DocStringStyleChecker
  32. def test_docstring_message(linter):
  33. docstring_test = osp.join(osp.dirname(osp.abspath(__file__)), 'data',
  34. 'docstring.py')
  35. linter.check([docstring_test])
  36. msgs = linter.reporter.messages
  37. assert len(msgs) == 7
  38. for msg, expected_symbol, expected_msg in zip(msgs,
  39. EXPECTED_SYMBOLS,
  40. EXPECTED_MSGS):
  41. assert msg.symbol == expected_symbol
  42. assert msg.msg == expected_msg