guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

11/12: gnu: python-nbconvert: Enable more tests.


From: guix-commits
Subject: 11/12: gnu: python-nbconvert: Enable more tests.
Date: Mon, 26 Apr 2021 04:37:52 -0400 (EDT)

lbraun pushed a commit to branch master
in repository guix.

commit d57341234d66ba71618ed401d8bb0a5986dc22db
Author: Lars-Dominik Braun <lars@6xq.net>
AuthorDate: Tue Apr 20 11:03:55 2021 +0200

    gnu: python-nbconvert: Enable more tests.
    
    Enables more tests and fixes a few paths.
    
    * gnu/packages/python-xyz.scm (python-nbconvert) [arguments]: Add new
    phase, fixing pandoc/LaTeX paths. Set required environment variables in
    'check phase.
    [inputs]: Add pandoc and texlive.
    [native-inputs]: Add missing inputs for tests.
    [propagated-inputs]: Add tornado, which is always required.
---
 gnu/packages/python-xyz.scm | 76 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 55 insertions(+), 21 deletions(-)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index ace191e..3942135 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -10665,32 +10665,64 @@ time.")
     (arguments
      `(#:phases
        (modify-phases %standard-phases
+         (add-after 'unpack 'fix-paths-and-tests
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((pandoc (string-append (assoc-ref inputs "pandoc") 
"/bin/pandoc"))
+                   (texlive-root (string-append (assoc-ref inputs "texlive")))
+                   (xelatex (string-append texlive-root "/bin/xelatex"))
+                   (bibtex (string-append texlive-root "/bin/bibtex")))
+               ;; Use pandoc binary from input.
+               (substitute* "nbconvert/utils/pandoc.py"
+                 (("'pandoc'") (string-append "'" pandoc "'")))
+               ;; Same for LaTeX.
+               (substitute* "nbconvert/exporters/pdf.py"
+                 (("\"xelatex\"") (string-append "\"" xelatex "\""))
+                 (("\"bibtex\"") (string-append "\"" bibtex "\"")))
+               ;; Make sure tests are not skipped.
+               (substitute* (find-files "." "test_.+\\.py$")
+                 (("@onlyif_cmds_exist\\(('(pandoc|xelatex)'(, )?)+\\)") ""))
+              ;; Pandoc is never missing, disable test.
+              (substitute* "nbconvert/utils/tests/test_pandoc.py"
+                (("import os" all) (string-append all "\nimport pytest"))
+                (("(.+)(def test_pandoc_available)" all indent def)
+                (string-append indent "@pytest.mark.skip('disabled by guix')\n"
+                               indent def)))
+              ; Not installing pyppeteer, delete test.
+              (delete-file "nbconvert/exporters/tests/test_webpdf.py")
+              (substitute* "nbconvert/tests/test_nbconvertapp.py"
+                (("(.+)(def test_webpdf_with_chromium)" all indent def)
+                (string-append indent "@pytest.mark.skip('disabled by guix')\n"
+                               indent def)))
+             #t)))
          (replace 'check
            (lambda* (#:key tests? inputs outputs #:allow-other-keys)
              (when tests?
+               ;; Some tests invoke the installed nbconvert binary.
                (add-installed-pythonpath inputs outputs)
-
-               ;; This seems to require Chromium.
-               (delete-file "nbconvert/exporters/tests/test_webpdf.py")
-
-               ;; This depends on the python3 kernel, which is provided by a
-               ;; package that depends on nbconvert.
-               (delete-file "nbconvert/preprocessors/tests/test_execute.py")
-
-               ;; Most of these tests fail because nbconvert fails to execute
-               ;; itself.
-               (delete-file "nbconvert/tests/test_nbconvertapp.py")
-
-               ;; One test here fails with an unclear error.  It looks like
-               ;; "%%pylabprint" is supposed to be expanded to some other
-               ;; code, but isn't.
-               (delete-file "nbconvert/filters/tests/test_strings.py")
-               
+               ;; Tries to write to this path.
+               (unsetenv "JUPYTER_CONFIG_DIR")
+               ;; Tests depend on templates installed to output.
+               (setenv "JUPYTER_PATH"
+                      (string-append
+                        (assoc-ref outputs "out")
+                        "/share/jupyter:"
+                        (getenv "JUPYTER_PATH")))
                ;; Some tests need HOME
                (setenv "HOME" "/tmp")
-               (invoke "pytest")))))))
-    (native-inputs
-     `(("python-pytest" ,python-pytest)))
+               (invoke "pytest" "-vv")))))))
+    (inputs
+      `(("pandoc" ,pandoc)
+        ; XXX: Disabled, needs substitute*.
+        ;("inkscape" ,inkscape)
+        ("texlive" ,texlive)))
+    (native-inputs
+      `(("python-ipykernel" ,python-ipykernel)
+        ; XXX: Disabled, not in guix.
+        ;("python-pyppeteer" ,python-pyppeteer)
+        ("python-pytest" ,python-pytest)
+        ("python-pytest-cov" ,python-pytest-cov)
+        ("python-pytest-dependency"
+         ,python-pytest-dependency)))
     (propagated-inputs
      `(("python-bleach" ,python-bleach)
        ("python-defusedxml" ,python-defusedxml)
@@ -10704,7 +10736,9 @@ time.")
        ("python-pygments" ,python-pygments)
        ("python-jupyterlab-pygments" ,python-jupyterlab-pygments)
        ("python-testpath" ,python-testpath)
-       ("python-traitlets" ,python-traitlets)))
+       ("python-traitlets" ,python-traitlets)
+       ;; Required, even if [serve] is not used.
+       ("python-tornado" ,python-tornado-6)))
     (home-page "https://jupyter.org";)
     (synopsis "Converting Jupyter Notebooks")
     (description "The @code{nbconvert} tool, @{jupyter nbconvert}, converts



reply via email to

[Prev in Thread] Current Thread [Next in Thread]