jupyter/jupyter-sphinx

0.4.0: pytest is failing in `tests/test_execute.py::test_save_script` unit because hardcoded python interpreter name

kloczek opened this issue ยท 2 comments

Looks like pytest is failing in tests/test_execute.py::test_save_script because hardcoded python interpreter name.
Insterd it should be used sys.executable.
pytest as well currently shows some PendingDeprecationWarning warnings.
Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-jupyter-sphinx-0.4.0-4.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-jupyter-sphinx-0.4.0-4.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.8.16, pytest-7.2.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0
collected 35 items

tests/test_execute.py ...........................Fs......                [100%]

=================================== FAILURES ===================================
_______________________________ test_save_script _______________________________

doctree = <function doctree.<locals>.doctree at 0x7fac32562040>

    def test_save_script(doctree):
        source = """
        .. jupyter-kernel:: python3
          :id: test

        .. jupyter-execute::

          a = 1
          print(a)
        """
        _, app, _ = doctree(source, return_all=True)
        outdir = Path(app.outdir)
        saved_text = (outdir / "../jupyter_execute/test.py").read_text()
>       assert saved_text.startswith("#!/usr/bin/python3")
E       AssertionError: assert False
E        +  where False = <built-in method startswith of str object at 0x7fac33135d30>('#!/usr/bin/python3')
E        +    where <built-in method startswith of str object at 0x7fac33135d30> = '#!/usr/bin/env python\n# coding: utf-8\n\n# In[1]:\n\n\na = 1\nprint(a)\n\n'.startswith

tests/test_execute.py:637: AssertionError
=============================== warnings summary ===============================
../../../../../usr/lib/python3.8/site-packages/jupyter_client/connect.py:27
  /usr/lib/python3.8/site-packages/jupyter_client/connect.py:27: DeprecationWarning: Jupyter is migrating its paths to use standard platformdirs
  given by the platformdirs library.  To remove this warning and
  see the appropriate new directories, set the environment variable
  `JUPYTER_PLATFORM_DIRS=1` and then run `jupyter --paths`.
  The use of platformdirs will be the default in `jupyter_core` v6
    from jupyter_core.paths import jupyter_data_dir

../../../../../usr/lib/python3.8/site-packages/traitlets/traitlets.py:1016: 98 warnings
  /usr/lib/python3.8/site-packages/traitlets/traitlets.py:1016: DeprecationWarning: Widget._active_widgets is deprecated.
    value = getattr(cls, name)

../../../../../usr/lib/python3.8/site-packages/traitlets/traitlets.py:1016: 98 warnings
  /usr/lib/python3.8/site-packages/traitlets/traitlets.py:1016: DeprecationWarning: Widget._widget_types is deprecated.
    value = getattr(cls, name)

../../../../../usr/lib/python3.8/site-packages/traitlets/traitlets.py:1016: 98 warnings
  /usr/lib/python3.8/site-packages/traitlets/traitlets.py:1016: DeprecationWarning: Widget.widget_types is deprecated.
    value = getattr(cls, name)

../../../../../usr/lib/python3.8/site-packages/traitlets/traitlets.py:1016: 98 warnings
  /usr/lib/python3.8/site-packages/traitlets/traitlets.py:1016: DeprecationWarning: Widget.widgets is deprecated.
    value = getattr(cls, name)

tests/test_execute.py::test_basic[html]
tests/test_execute.py::test_basic[html]
  /usr/lib64/python3.8/importlib/__init__.py:127: RemovedInSphinx80Warning: The alias 'sphinx.util.progress_message' is deprecated, use 'sphinx.util.display.progress_message' instead. Check CHANGES for Sphinx API modifications.
    return _bootstrap._gcd_import(name[level:], package, level)

tests/test_execute.py: 40 warnings
  /home/tkloczko/rpmbuild/BUILDROOT/python-jupyter-sphinx-0.4.0-4.fc35.x86_64/usr/lib/python3.8/site-packages/jupyter_sphinx/ast.py:628: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    for cell_node in self.document.traverse(JupyterCellNode):

tests/test_execute.py: 39 warnings
  /home/tkloczko/rpmbuild/BUILDROOT/python-jupyter-sphinx-0.4.0-4.fc35.x86_64/usr/lib/python3.8/site-packages/jupyter_sphinx/execute.py:126: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    if not doctree.traverse(JupyterCellNode):

tests/test_execute.py: 38 warnings
  /home/tkloczko/rpmbuild/BUILDROOT/python-jupyter-sphinx-0.4.0-4.fc35.x86_64/usr/lib/python3.8/site-packages/jupyter_sphinx/execute.py:143: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    doctree.traverse(lambda n: isinstance(n, jupyter_nodes)),

tests/test_execute.py::test_basic[html]
tests/test_execute.py::test_basic[singlehtml]
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:82: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_hide_output
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:100: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_hide_code
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:115: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_code_below
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:130: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_linenos
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:145: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_linenos
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:159: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_linenos_conf_option
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:171: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_continue_linenos_conf_option
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:189: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_continue_linenos_conf_option
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:213: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    cell0, cell1 = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_continue_linenos_conf_option
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:243: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    cell0, cell1 = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_emphasize_lines
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:277: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    cell0, cell1 = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_execution_environment_carries_over
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:295: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    _, cell1 = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_kernel_restart
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:316: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    _, cell1 = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_raises
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:337: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_raises
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:348: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_widgets
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:361: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    assert len(list(tree.traverse(JupyterWidgetViewNode))) == 1

tests/test_execute.py::test_widgets
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:362: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    assert len(list(tree.traverse(JupyterWidgetStateNode))) == 1

tests/test_execute.py::test_javascript
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:373: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (node,) = list(tree.traverse(raw))

tests/test_execute.py::test_stdout
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:385: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_stderr
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:401: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_stderr
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:413: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_thebe_hide_output
tests/test_execute.py::test_thebe_hide_code
tests/test_execute.py::test_thebe_code_below
tests/test_execute.py::test_thebe_button_auto
tests/test_execute.py::test_thebe_button_manual
  /home/tkloczko/rpmbuild/BUILDROOT/python-jupyter-sphinx-0.4.0-4.fc35.x86_64/usr/lib/python3.8/site-packages/jupyter_sphinx/execute.py:131: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    if not doctree.traverse(ThebeButtonNode):

tests/test_execute.py::test_thebe_hide_output
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:431: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_thebe_hide_code
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:450: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_thebe_code_below
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:475: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_thebe_button_auto
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:499: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    assert len(tree.traverse(ThebeButtonNode)) == 1

tests/test_execute.py::test_thebe_button_manual
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:512: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    assert len(tree.traverse(ThebeButtonNode)) == 1

tests/test_execute.py::test_thebe_button_none
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:519: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    assert len(tree.traverse(ThebeButtonNode)) == 0

tests/test_execute.py::test_latex
tests/test_execute.py::test_latex
tests/test_execute.py::test_latex
tests/test_execute.py::test_latex
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:534: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_latex
tests/test_execute.py::test_latex
tests/test_execute.py::test_latex
tests/test_execute.py::test_latex
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:536: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    assert next(iter(celloutput.traverse(math_block))).astext() == r"\int"

tests/test_execute.py::test_cell_output_to_nodes
tests/test_execute.py::test_cell_output_to_nodes
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:577: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (image_node,) = output_node.traverse(image)

tests/test_execute.py::test_input_cell
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:675: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_input_cell_linenos
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:691: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_output_cell
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:710: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (cell,) = tree.traverse(JupyterCellNode)

tests/test_execute.py::test_multiple_directives
  /home/tkloczko/rpmbuild/BUILD/jupyter-sphinx-0.4.0/tests/test_execute.py:744: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
    (ex, jin) = tree.traverse(JupyterCellNode)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
SKIPPED [1] tests/test_execute.py:642: could not import 'bash_kernel': No module named 'bash_kernel'
FAILED tests/test_execute.py::test_save_script - AssertionError: assert False
======= 1 failed, 33 passed, 1 skipped, 559 warnings in 80.16s (0:01:20) =======

I think I'm facing the same issue in my most recent builds: https://readthedocs.org/projects/pygaul/builds/21575953/

In short:

Unable to find kernel (exception: No such kernel named python3)

I solved my issue by adding "ipykernel" in my documentation deps, it's urprising that it's not already included by one of jupyter-sphinx's