From a6773258cf6fe1acc5520f56ef948ba6975cbe32 Mon Sep 17 00:00:00 2001 From: Liu Hui Date: Wed, 21 Feb 2024 12:40:06 +0800 Subject: [PATCH] Fix Python shell completion test failures * test/lisp/progmodes/python-tests.el (python-tests-with-temp-buffer-with-shell): Set XDG_CACHE_HOME to a temporary directory. (bug#68559) --- test/lisp/progmodes/python-tests.el | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el index af6c199b5bd..6454cfcc2b7 100644 --- a/test/lisp/progmodes/python-tests.el +++ b/test/lisp/progmodes/python-tests.el @@ -60,12 +60,17 @@ python-tests-with-temp-buffer-with-shell (python-shell-completion-native-enable nil)) (python-mode) (unwind-protect - (progn - (run-python nil t) - (insert ,contents) - (goto-char (point-min)) - (python-tests-shell-wait-for-prompt) - ,@body) + ;; Prevent test failures when Jedi is used as a completion + ;; backend, either directly or indirectly (e.g., via + ;; IPython). Jedi needs to store cache, but the + ;; "/nonexistent" HOME directory is not writable. + (ert-with-temp-directory cache-dir + (with-environment-variables (("XDG_CACHE_HOME" cache-dir)) + (run-python nil t) + (insert ,contents) + (goto-char (point-min)) + (python-tests-shell-wait-for-prompt) + ,@body)) (when (python-shell-get-buffer) (python-shell-with-shell-buffer (let (kill-buffer-hook kill-buffer-query-functions) -- 2.25.1