third_party.pylibs.pylint.src/tests/extensions/test_elseif_used.py

33 lines
1006 B
Python
Raw Normal View History

2018-07-15 09:36:36 +00:00
# Copyright (c) 2015-2017 Claudiu Popa <pcmanticore@gmail.com>
2017-12-15 11:24:15 +00:00
# Copyright (c) 2015 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr>
# Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com>
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
2015-11-30 13:43:04 +00:00
"""Tests for the pylint checker in :mod:`pylint.extensions.check_elif
"""
import os.path as osp
2016-12-08 04:15:21 +00:00
import pytest
from pylint.extensions.check_elif import ElseifUsedChecker
2015-11-30 13:43:04 +00:00
2016-12-08 04:15:21 +00:00
@pytest.fixture(scope="module")
2017-01-03 07:05:38 +00:00
def checker(checker):
return ElseifUsedChecker
2016-12-08 04:15:21 +00:00
def test_elseif_message(linter):
elif_test = osp.join(osp.dirname(osp.abspath(__file__)), "data", "elif.py")
2016-12-08 04:15:21 +00:00
linter.check([elif_test])
msgs = linter.reporter.messages
assert len(msgs) == 2
for msg in msgs:
assert msg.symbol == "else-if-used"
2016-12-08 04:15:21 +00:00
assert msg.msg == 'Consider using "elif" instead of "else if"'
assert msgs[0].line == 9
assert msgs[1].line == 21