Skip to content

Commit 106ac13

Browse files
Simplify 'test_can_read_toml_env_variable' to work like other tests
See initial intent in #3839 This permit to not use the OptionManagerMixin directly, which is problematic when it needs the function defined in Pylinter or other classes.
1 parent 57515ae commit 106ac13

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

tests/config/test_config.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# pylint: disable=missing-module-docstring, missing-function-docstring, protected-access
22
import os
33
import unittest.mock
4-
from pathlib import PosixPath
5-
6-
import pytest
4+
from pathlib import Path, PosixPath
5+
from typing import Union
76

87
import pylint.lint
9-
from pylint.config import OptionsManagerMixIn
108
from pylint.lint.run import Run
119

1210

13-
def check_configuration_file_reader(config_file: PosixPath) -> Run:
11+
def check_configuration_file_reader(config_file: Union[str, Path]) -> Run:
1412
"""Initialize pylint with the given configuration file and check that
1513
what we initialized the linter with what was expected.
1614
"""
@@ -110,17 +108,6 @@ def test_can_read_toml_env_variable(tmp_path: PosixPath) -> None:
110108
reports = "yes"
111109
"""
112110
)
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

Comments
 (0)