summaryrefslogtreecommitdiff
path: root/tests/test_epylint.py
blob: 525627166736bccbb35a0fe41013b6b0ff6ffb41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Test for issue https://github.com/PyCQA/pylint/issues/4286"""
# pylint: disable=redefined-outer-name
import pytest

from pylint import epylint as lint


@pytest.fixture()
def example_path(tmp_path):
    content = """class IvrAudioApp:

    def run(self):
        self.hassan()
    """
    path = tmp_path / "my_app.py"
    with open(path, "w", encoding="utf-8") as f:
        f.write(content)
    return path


def test_epylint_good_command(example_path):
    out, err = lint.py_run(
        "%s -E --disable=E1111 --msg-template '{category} {module} {obj} {line} {column} {msg}'"
        % example_path,
        return_std=True,
    )
    msg = out.read()
    assert (
        msg
        == """\
************* Module my_app
 error my_app IvrAudioApp.run 4 8 Instance of 'IvrAudioApp' has no 'hassan' member
 """
    )
    assert err.read() == ""


def test_epylint_strange_command(example_path):
    out, err = lint.py_run(
        "%s -E --disable=E1111 --msg-template={category} {module} {obj} {line} {column} {msg}"
        % example_path,
        return_std=True,
    )
    assert (
        out.read()
        == """\
************* Module {module}
 fatal
 ************* Module {obj}
 fatal
 ************* Module {line}
 fatal
 ************* Module {column}
 fatal
 ************* Module {msg}
 fatal
 ************* Module my_app
 error
 """
    )
    assert err.read() == ""