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
|
# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt
# pylint: disable=missing-module-docstring, missing-function-docstring
import os
import sys
from typing import Callable
from unittest.mock import patch
import pytest
from py._path.local import LocalPath # type: ignore[import]
from pylint import run_epylint, run_pylint, run_pyreverse, run_symilar
@pytest.mark.parametrize(
"runner", [run_epylint, run_pylint, run_pyreverse, run_symilar]
)
def test_runner(runner: Callable, tmpdir: LocalPath) -> None:
filepath = os.path.abspath(__file__)
testargs = ["", filepath]
with tmpdir.as_cwd():
with patch.object(sys, "argv", testargs):
with pytest.raises(SystemExit) as err:
runner()
assert err.value.code == 0
@pytest.mark.parametrize(
"runner", [run_epylint, run_pylint, run_pyreverse, run_symilar]
)
def test_runner_with_arguments(runner: Callable, tmpdir: LocalPath) -> None:
"""Check the runners with arguments as parameter instead of sys.argv."""
filepath = os.path.abspath(__file__)
testargs = [filepath]
with tmpdir.as_cwd():
with pytest.raises(SystemExit) as err:
runner(testargs)
assert err.value.code == 0
|