diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2021-04-20 11:03:55 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2021-04-26 10:26:48 +0200 |
commit | d57341234d66ba71618ed401d8bb0a5986dc22db (patch) | |
tree | a6bbdcfbba8718404a133b9491fd14f333a57618 | |
parent | 9857abadbabbe29b67a20d18b1e801c1c66c9d6c (diff) | |
download | guix-d57341234d66ba71618ed401d8bb0a5986dc22db.tar.gz |
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.
-rw-r--r-- | gnu/packages/python-xyz.scm | 76 |
1 files changed, 55 insertions, 21 deletions
diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm index ace191e227..3942135ae3 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 |