|
1 | 1 | # pylint: disable=missing-module-docstring, missing-function-docstring, protected-access
|
2 | 2 | import os
|
3 | 3 | import unittest.mock
|
4 |
| -from pathlib import PosixPath |
5 |
| - |
6 |
| -import pytest |
| 4 | +from pathlib import Path, PosixPath |
| 5 | +from typing import Union |
7 | 6 |
|
8 | 7 | import pylint.lint
|
9 |
| -from pylint.config import OptionsManagerMixIn |
10 | 8 | from pylint.lint.run import Run
|
11 | 9 |
|
12 | 10 |
|
13 |
| -def check_configuration_file_reader(config_file: PosixPath) -> Run: |
| 11 | +def check_configuration_file_reader(config_file: Union[str, Path]) -> Run: |
14 | 12 | """Initialize pylint with the given configuration file and check that
|
15 | 13 | what we initialized the linter with what was expected.
|
16 | 14 | """
|
@@ -110,17 +108,6 @@ def test_can_read_toml_env_variable(tmp_path: PosixPath) -> None:
|
110 | 108 | reports = "yes"
|
111 | 109 | """
|
112 | 110 | )
|
113 |
| - os.environ["tmp_path_env"] = str(tmp_path / "pyproject.toml") |
114 |
| - options_manager_mix_in = OptionsManagerMixIn("", "${tmp_path_env}") |
115 |
| - options_manager_mix_in.read_config_file("${tmp_path_env}") |
116 |
| - |
117 |
| - def test_read_config_file() -> None: |
118 |
| - with pytest.raises(OSError): |
119 |
| - options_manager_mix_in.read_config_file("${tmp_path_en}") |
120 |
| - |
121 |
| - test_read_config_file() |
122 |
| - options_manager_mix_in.load_config_file() |
123 |
| - section = options_manager_mix_in.cfgfile_parser.sections()[0] |
124 |
| - jobs, jobs_nr = options_manager_mix_in.cfgfile_parser.items(section)[1] |
125 |
| - assert jobs == "jobs" |
126 |
| - assert jobs_nr == "10" |
| 111 | + env_var = "tmp_path_env" |
| 112 | + os.environ[env_var] = str(config_file) |
| 113 | + check_configuration_file_reader(f"${env_var}") |
0 commit comments