From 7c9801e857d2afed6187645b2139facf61a4204b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Fri, 19 Nov 2021 21:27:18 +0100 Subject: [PATCH] gnu: python-notebook: Fix tests that rely on the gio "trash" mechanism. Previously 'test_delete' and a couple of related tests in 'test_content_api.py' would fail: https://lists.gnu.org/archive/html/guix-devel/2021-11/msg00083.html Reported by Ricardo Wurmus. * gnu/packages/python-xyz.scm (python-notebook)[arguments]: Add 'use-our-home-for-tests' phase. In 'check' phase, remove call to 'setenv' and unnecessary use of 'with-directory-excursion'. --- gnu/packages/python-xyz.scm | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm index e882659d4b..3f314ec143 100644 --- a/gnu/packages/python-xyz.scm +++ b/gnu/packages/python-xyz.scm @@ -12051,6 +12051,18 @@ (define-public python-notebook (arguments `(#:phases (modify-phases %standard-phases + (add-after 'unpack 'use-our-home-for-tests + (lambda _ + ;; The 'get_patch_env' function in this file reads: + ;; 'HOME': cls.home_dir + ;; but for some reason, that definition of HOME is not what the + ;; GLib/GIO trash mechanism honors, which would cause test + ;; failures. Instead, set 'HOME' here to an existing directory + ;; and let the tests honor it. + (substitute* "notebook/tests/launchnotebook.py" + (("'HOME': .*," all) + (string-append "# " all "\n"))) + (setenv "HOME" (getcwd)))) (replace 'check (lambda* (#:key tests? inputs outputs #:allow-other-keys) ;; These tests require a browser @@ -12060,13 +12072,10 @@ (define-public python-notebook ;; Some tests do not expect all files to be installed in the ;; same directory, but JUPYTER_PATH contains multiple entries. (unsetenv "JUPYTER_PATH") - ;; Some tests need HOME - (setenv "HOME" "/tmp") - (with-directory-excursion "/tmp" - (invoke "pytest" "-vv" - ;; TODO: This tests fails because nbconvert does not - ;; list "python" as a format. - "-k" "not test_list_formats")))))))) + (invoke "pytest" "-vv" + ;; TODO: This tests fails because nbconvert does not + ;; list "python" as a format. + "-k" "not test_list_formats"))))))) (propagated-inputs `(("python-argon2-cffi" ,python-argon2-cffi) ("python-ipykernel" ,python-ipykernel)