diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-11-08 23:24:58 +0100 |
---|---|---|
committer | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2021-11-10 00:01:52 +0100 |
commit | 106ac13f295c5705812e47ec043045d87a9b948a (patch) | |
tree | a45342f5ac104bf25c548a8db844c362035b3687 | |
parent | 57515ae304c9e4bae6a94f08ea7ef2d6fadc61ce (diff) | |
download | pylint-git-106ac13f295c5705812e47ec043045d87a9b948a.tar.gz |
Simplify 'test_can_read_toml_env_variable' to work like other tests
See initial intent in https://github.com/PyCQA/pylint/issues/3839
This permit to not use the OptionManagerMixin directly, which is
problematic when it needs the function defined in Pylinter or
other classes.
-rw-r--r-- | tests/config/test_config.py | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/tests/config/test_config.py b/tests/config/test_config.py index daf04bbfa..65bc586fd 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -1,16 +1,14 @@ # pylint: disable=missing-module-docstring, missing-function-docstring, protected-access import os import unittest.mock -from pathlib import PosixPath - -import pytest +from pathlib import Path, PosixPath +from typing import Union import pylint.lint -from pylint.config import OptionsManagerMixIn from pylint.lint.run import Run -def check_configuration_file_reader(config_file: PosixPath) -> Run: +def check_configuration_file_reader(config_file: Union[str, Path]) -> Run: """Initialize pylint with the given configuration file and check that what we initialized the linter with what was expected. """ @@ -110,17 +108,6 @@ jobs = "10" reports = "yes" """ ) - os.environ["tmp_path_env"] = str(tmp_path / "pyproject.toml") - options_manager_mix_in = OptionsManagerMixIn("", "${tmp_path_env}") - options_manager_mix_in.read_config_file("${tmp_path_env}") - - def test_read_config_file() -> None: - with pytest.raises(OSError): - options_manager_mix_in.read_config_file("${tmp_path_en}") - - test_read_config_file() - options_manager_mix_in.load_config_file() - section = options_manager_mix_in.cfgfile_parser.sections()[0] - jobs, jobs_nr = options_manager_mix_in.cfgfile_parser.items(section)[1] - assert jobs == "jobs" - assert jobs_nr == "10" + env_var = "tmp_path_env" + os.environ[env_var] = str(config_file) + check_configuration_file_reader(f"${env_var}") |