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

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (c) 2016-2017 Claudiu Popa <pcmanticore@gmail.com>
  2. # Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com>
  3. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  4. # For details: https://github.com/PyCQA/pylint/blob/master/COPYING
  5. """Tests for the pylint checker in :mod:`pylint.extensions.bad_builtin
  6. """
  7. import os.path as osp
  8. import pytest
  9. from pylint.extensions.bad_builtin import BadBuiltinChecker
  10. from pylint.lint import fix_import_path
  11. EXPECTED = [
  12. "Used builtin function 'map'. Using a list comprehension can be clearer.",
  13. "Used builtin function 'filter'. Using a list comprehension can be clearer.",
  14. ]
  15. @pytest.fixture(scope='module')
  16. def checker(checker):
  17. return BadBuiltinChecker
  18. @pytest.fixture(scope='module')
  19. def disable(disable):
  20. return ['I']
  21. def test_types_redefined(linter):
  22. elif_test = osp.join(osp.dirname(osp.abspath(__file__)), 'data',
  23. 'bad_builtin.py')
  24. with fix_import_path([elif_test]):
  25. linter.check([elif_test])
  26. msgs = sorted(linter.reporter.messages, key=lambda item: item.line)
  27. assert len(msgs) == 2
  28. for msg, expected in zip(msgs, EXPECTED):
  29. assert msg.symbol == 'bad-builtin'
  30. assert msg.msg == expected