From 749a7f3347503b38bbd2825e55a739d64e30eebf Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 8 Nov 2021 23:24:58 +0100 Subject: [PATCH] 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. --- tests/config/test_config.py | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/tests/config/test_config.py b/tests/config/test_config.py index daf04bbfa0..65bc586fd2 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 @@ def test_can_read_toml_env_variable(tmp_path: PosixPath) -> None: 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}")