Skip to content

Commit

Permalink
Simplify 'test_can_read_toml_env_variable' to work like other tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Pierre-Sassoulas committed Nov 9, 2021
1 parent 57515ae commit 749a7f3
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions 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.
"""
Expand Down Expand Up @@ -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}")

0 comments on commit 749a7f3

Please sign in to comment.