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_emptystring.py 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # -*- coding: utf-8 -*-
  2. # Copyright (c) 2016 Łukasz Rogalski <rogalski.91@gmail.com>
  3. # Copyright (c) 2016 Alexander Todorov <atodorov@otb.bg>
  4. # Copyright (c) 2017 Claudiu Popa <pcmanticore@gmail.com>
  5. # Copyright (c) 2017 Derek Gustafson <degustaf@gmail.com>
  6. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  7. # For details: https://github.com/PyCQA/pylint/blob/master/COPYING
  8. """Tests for the pylint checker in :mod:`pylint.extensions.emptystring
  9. """
  10. import os.path as osp
  11. import pytest
  12. from pylint.extensions.emptystring import CompareToEmptyStringChecker
  13. @pytest.fixture(scope='module')
  14. def checker(checker):
  15. return CompareToEmptyStringChecker
  16. @pytest.fixture(scope='module')
  17. def disable(disable):
  18. return ['I']
  19. def test_emptystring_message(linter):
  20. elif_test = osp.join(osp.dirname(osp.abspath(__file__)), 'data',
  21. 'empty_string_comparison.py')
  22. linter.check([elif_test])
  23. msgs = linter.reporter.messages
  24. expected_lineno = [6, 9, 12, 15]
  25. assert len(msgs) == len(expected_lineno)
  26. for msg, lineno in zip(msgs, expected_lineno):
  27. assert msg.symbol == 'compare-to-empty-string'
  28. assert msg.msg == 'Avoid comparisons to empty string'
  29. assert msg.line == lineno