|
12 | 12 | import unittest
|
13 | 13 | from pathlib import Path
|
14 | 14 | from typing import Any, Dict
|
15 |
| -from unittest.mock import Mock |
16 | 15 |
|
17 | 16 | from pylint.lint import Run
|
18 | 17 |
|
@@ -135,18 +134,15 @@ def get_expected_output(
|
135 | 134 |
|
136 | 135 | def run_using_a_configuration_file(
|
137 | 136 | configuration_path: Path | str, file_to_lint: str = __file__
|
138 |
| -) -> tuple[Mock, Mock, Run]: |
| 137 | +) -> Run: |
139 | 138 | """Simulate a run with a configuration without really launching the checks."""
|
140 | 139 | configuration_path = str(configuration_path)
|
141 | 140 | args = ["--rcfile", configuration_path, file_to_lint]
|
142 |
| - # We do not capture the `SystemExit` as then the `runner` variable |
143 |
| - # would not be accessible outside the `with` block. |
144 |
| - with unittest.mock.patch("sys.exit") as mocked_exit: |
145 |
| - # Do not actually run checks, that could be slow. We don't mock |
146 |
| - # `PyLinter.check`: it calls `PyLinter.initialize` which is |
147 |
| - # needed to properly set up messages inclusion/exclusion |
148 |
| - # in `_msg_states`, used by `is_message_enabled`. |
149 |
| - check = "pylint.lint.pylinter.check_parallel" |
150 |
| - with unittest.mock.patch(check) as mocked_check_parallel: |
151 |
| - runner = Run(args) |
152 |
| - return mocked_exit, mocked_check_parallel, runner |
| 141 | + # Do not actually run checks, that could be slow. We don't mock |
| 142 | + # `PyLinter.check`: it calls `PyLinter.initialize` which is |
| 143 | + # needed to properly set up messages inclusion/exclusion |
| 144 | + # in `_msg_states`, used by `is_message_enabled`. |
| 145 | + check = "pylint.lint.pylinter.check_parallel" |
| 146 | + with unittest.mock.patch(check): |
| 147 | + runner = Run(args, exit=False) |
| 148 | + return runner |
0 commit comments