Skip to content

Commit

Permalink
Adding check for dict
Browse files Browse the repository at this point in the history
  • Loading branch information
tanvimoharir authored and Pierre-Sassoulas committed Nov 8, 2021
1 parent 35cdd07 commit e2c7577
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ contributors:

* Marcin Kurczewski (rr-): contributor

* Tanvi Moharir: contributor
- Fix for invalid toml config

* Eisuke Kawashima (e-kwsm): contributor

* Daniel van Noord (DanielNoord): contributor
Expand Down
51 changes: 51 additions & 0 deletions tests/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,54 @@ def test_read_config_file() -> None:
jobs, jobs_nr = options_manager_mix_in.cfgfile_parser.items(section)[1]
assert jobs == "jobs"
assert jobs_nr == "10"


def test_toml_with_empty_list_for_plugins(tmp_path):
# This would check that there is no crash for when empty lists
# passed as plugins , refer #4580
config_file = tmp_path / "pyproject.toml"
config_file.write_text(
"""
[tool.pylint]
disable = "logging-not-lazy,logging-format-interpolation"
load-plugins = []
"""
)
with pytest.raises(AttributeError):
check_configuration_file_reader(config_file)


def test_toml_with_invalid_data_for_imports(tmp_path):
# This would test config with invalid data for imports section
# refer #4580
config_file = tmp_path / "pyproject.toml"
config_file.write_text(
"""
[tool.pylint."imports"]
disable = [
"logging-not-lazy",
"logging-format-interpolation",
]
preferred-modules = { "a"="b" }
"""
)
with pytest.raises(AttributeError):
check_configuration_file_reader(config_file)


def test_toml_with_invalid_data_for_basic(tmp_path):
# This would test config with invalid data for basic section
# refer #4580
config_file = tmp_path / "pyproject.toml"
config_file.write_text(
"""
[tool.pylint."basic"]
disable = [
"logging-not-lazy",
"logging-format-interpolation",
]
name-group = { "a"="b" }
"""
)
with pytest.raises(AttributeError):
check_configuration_file_reader(config_file)

0 comments on commit e2c7577

Please sign in to comment.