summaryrefslogtreecommitdiff
path: root/tests/config
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-06-02 19:43:58 +0200
committerGitHub <noreply@github.com>2022-06-02 19:43:58 +0200
commitdee9de56f84837be3de915aec8c2e9629dd9c548 (patch)
treebb6970562ac3dc60932d4012797544e3a4430b53 /tests/config
parentdc7b03266fad7e885da1374ac312dfc0b63ebbfd (diff)
downloadpylint-git-dee9de56f84837be3de915aec8c2e9629dd9c548.tar.gz
Don't crash if we can't find the user's home directory (#6806)
Diffstat (limited to 'tests/config')
-rw-r--r--tests/config/test_find_default_config_files.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/config/test_find_default_config_files.py b/tests/config/test_find_default_config_files.py
index 0872c3d88..cf588bdd7 100644
--- a/tests/config/test_find_default_config_files.py
+++ b/tests/config/test_find_default_config_files.py
@@ -12,6 +12,7 @@ import sys
import tempfile
from collections.abc import Iterator
from pathlib import Path
+from unittest import mock
import pytest
from pytest import CaptureFixture
@@ -223,3 +224,17 @@ def test_cfg_has_config(content: str, expected: str, tmp_path: Path) -> None:
with open(fake_cfg, "w", encoding="utf8") as f:
f.write(content)
assert _cfg_has_config(fake_cfg) == expected
+
+
+def test_non_existent_home() -> None:
+ """Test that we handle a non-existent home directory.
+
+ Reported in https://github.com/PyCQA/pylint/issues/6802.
+ """
+ with mock.patch("pathlib.Path.home", side_effect=RuntimeError):
+ current_dir = os.getcwd()
+ os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
+
+ assert not list(config.find_default_config_files())
+
+ os.chdir(current_dir)