Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest is failing in two tests/test_nbconvertapp.py units (7.11.0 - 7.16.0) #2066

Closed
kloczek opened this issue Nov 6, 2023 · 2 comments · Fixed by #2108
Closed

pytest is failing in two tests/test_nbconvertapp.py units (7.11.0 - 7.16.0) #2066

kloczek opened this issue Nov 6, 2023 · 2 comments · Fixed by #2108
Labels

Comments

@kloczek
Copy link

kloczek commented Nov 6, 2023

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix> using 'installer` module
  • run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
  • build is performed in env which is cut off from access to the public network (pytest is executed with -m "not network")

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-nbconvert-7.11.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-nbconvert-7.11.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
============================= test session starts ==============================
platform linux -- Python 3.8.18, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/nbconvert-7.11.0
configfile: pyproject.toml
testpaths: tests/
plugins: cov-4.1.0, dependency-0.5.1, flaky-3.7.0
collected 320 items / 2 deselected / 318 selected

tests/test_nbconvertapp.py ........F...........ss.....s.........s.F..... [ 14%]
..                                                                       [ 14%]
tests/exporters/test_asciidoc.py .....                                   [ 16%]
tests/exporters/test_export.py ............                              [ 20%]
tests/exporters/test_exporter.py ........                                [ 22%]
tests/exporters/test_html.py ..................                          [ 28%]
tests/exporters/test_latex.py ............                               [ 32%]
tests/exporters/test_markdown.py ....                                    [ 33%]
tests/exporters/test_notebook.py .....                                   [ 34%]
tests/exporters/test_pdf.py ..s.s                                        [ 36%]
tests/exporters/test_python.py ....                                      [ 37%]
tests/exporters/test_qtpdf.py .ss                                        [ 38%]
tests/exporters/test_qtpng.py .ss                                        [ 39%]
tests/exporters/test_rst.py ......                                       [ 41%]
tests/exporters/test_script.py .......                                   [ 43%]
tests/exporters/test_slides.py ......                                    [ 45%]
tests/exporters/test_templateexporter.py ............................... [ 55%]
...........                                                              [ 58%]
tests/exporters/test_webpdf.py .sss                                      [ 60%]
tests/filters/test_ansi.py ...                                           [ 61%]
tests/filters/test_citation.py ...................                       [ 66%]
tests/filters/test_datatypefilter.py ...                                 [ 67%]
tests/filters/test_highlight.py ....                                     [ 69%]
tests/filters/test_latex.py .                                            [ 69%]
tests/filters/test_markdown.py ..........                                [ 72%]
tests/filters/test_metadata.py .                                         [ 72%]
tests/filters/test_pandoc.py ..                                          [ 73%]
tests/filters/test_strings.py ..............                             [ 77%]
tests/postprocessors/test_serve.py .                                     [ 78%]
tests/preprocessors/test_clearmetadata.py .........                      [ 81%]
tests/preprocessors/test_clearoutput.py ..                               [ 81%]
tests/preprocessors/test_coalescestreams.py ...                          [ 82%]
tests/preprocessors/test_csshtmlheader.py ..                             [ 83%]
tests/preprocessors/test_execute.py .....                                [ 84%]
tests/preprocessors/test_extractattachments.py ....                      [ 86%]
tests/preprocessors/test_extractoutput.py ...                            [ 87%]
tests/preprocessors/test_highlightmagics.py ...                          [ 88%]
tests/preprocessors/test_latex.py ...                                    [ 88%]
tests/preprocessors/test_regexremove.py ..                               [ 89%]
tests/preprocessors/test_sanitize.py .........                           [ 92%]
tests/preprocessors/test_svg2pdf.py .....                                [ 94%]
tests/preprocessors/test_tagremove.py ..                                 [ 94%]
tests/utils/test_io.py ..                                                [ 95%]
tests/utils/test_pandoc.py ..                                            [ 95%]
tests/utils/test_version.py .                                            [ 96%]
tests/writers/test_debug.py .                                            [ 96%]
tests/writers/test_files.py ..........                                   [ 99%]
tests/writers/test_stdout.py .                                           [100%]

=================================== FAILURES ===================================
______________ TestNbConvertApp.test_convert_full_qualified_name _______________

self = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_convert_full_qualified_name>

    def test_convert_full_qualified_name(self):
        """
        Test that nbconvert can convert file using a full qualified name for a
        package, import and use it.
        """
        with self.create_temp_cwd():
            self.copy_files_to(["notebook*.ipynb"], "subdir")
>           self.nbconvert(
                "--to tests.fake_exporters.MyExporter --log-level 0 "
                + os.path.join("subdir", "*.ipynb")
            )

self       = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_convert_full_qualified_name>

tests/test_nbconvertapp.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_convert_full_qualified_name>
parameters = ['--to', 'tests.fake_exporters.MyExporter', '--log-level', '0', 'subdir/*.ipynb']
ignore_return_code = False, stdin = None

    def nbconvert(self, parameters, ignore_return_code=False, stdin=None):
        """
        Run nbconvert as a shell command, listening for both Errors and
        non-zero return codes. Returns the tuple (stdout, stderr) of
        output produced during the nbconvert run.

        Parameters
        ----------
        parameters : str, list(str)
            List of parameters to pass to IPython.
        ignore_return_code : optional bool (default False)
            Throw an OSError if the return code
        """
        cmd = [sys.executable, "-m", "nbconvert"]
        if sys.platform == "win32":
            if isinstance(parameters, (str,)):
                cmd = " ".join(cmd) + " " + parameters
            else:
                cmd = " ".join(cmd + parameters)
        else:
            if isinstance(parameters, (str,)):
                parameters = shlex.split(parameters)
            cmd += parameters
        p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)  # noqa
        stdout, stderr = p.communicate(input=stdin)
        if not (p.returncode == 0 or ignore_return_code):
>           raise OSError(stderr.decode("utf8", "replace"))
E           OSError: [NbConvertApp] Searching ['/home/tkloczko/.jupyter', '/home/tkloczko/.local/etc/jupyter', '/usr/etc/jupyter', '/etc/jupyter'] for config files
E           [NbConvertApp] Looking for jupyter_config in /etc/jupyter
E           [NbConvertApp] Looking for jupyter_config in /usr/etc/jupyter
E           [NbConvertApp] Looking for jupyter_config in /home/tkloczko/.local/etc/jupyter
E           [NbConvertApp] Looking for jupyter_config in /home/tkloczko/.jupyter
E           [NbConvertApp] Looking for jupyter_nbconvert_config in /etc/jupyter
E           [NbConvertApp] Looking for jupyter_nbconvert_config in /usr/etc/jupyter
E           [NbConvertApp] Looking for jupyter_nbconvert_config in /home/tkloczko/.local/etc/jupyter
E           [NbConvertApp] Looking for jupyter_nbconvert_config in /home/tkloczko/.jupyter
E           [NbConvertApp] ERROR | Error importing tests.fake_exporters.MyExporter
E           Traceback (most recent call last):
E             File "/home/tkloczko/rpmbuild/BUILDROOT/python-nbconvert-7.11.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/nbconvert/exporters/base.py", line 120, in get_exporter
E               exporter = import_item(name)
E             File "/usr/lib/python3.8/site-packages/traitlets/utils/importstring.py", line 31, in import_item
E               module = __import__(package, fromlist=[obj])
E           ModuleNotFoundError: No module named 'tests'
E           Traceback (most recent call last):
E             File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
E               return _run_code(code, main_globals, None,
E             File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
E               exec(code, run_globals)
E             File "/home/tkloczko/rpmbuild/BUILDROOT/python-nbconvert-7.11.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/nbconvert/__main__.py", line 4, in <module>
E               main()
E             File "/usr/lib/python3.8/site-packages/jupyter_core/application.py", line 285, in launch_instance
E               return super().launch_instance(argv=argv, **kwargs)
E             File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 1053, in launch_instance
E               app.start()
E             File "/home/tkloczko/rpmbuild/BUILDROOT/python-nbconvert-7.11.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 412, in start
E               self.convert_notebooks()
E             File "/home/tkloczko/rpmbuild/BUILDROOT/python-nbconvert-7.11.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 578, in convert_notebooks
E               cls = get_exporter(self.export_format)
E             File "/home/tkloczko/rpmbuild/BUILDROOT/python-nbconvert-7.11.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/nbconvert/exporters/base.py", line 132, in get_exporter
E               raise ExporterNameError(msg)
E           nbconvert.exporters.base.ExporterNameError: Unknown exporter "tests.fake_exporters.MyExporter", did you mean one of: asciidoc, custom, html, latex, markdown, notebook, pdf, python, qtpdf, qtpng, rst, script, slides, webpdf?

cmd        = ['/usr/bin/python3', '-m', 'nbconvert', '--to', 'tests.fake_exporters.MyExporter', '--log-level', ...]
ignore_return_code = False
p          = <subprocess.Popen object at 0x7fb9f930e1f0>
parameters = ['--to', 'tests.fake_exporters.MyExporter', '--log-level', '0', 'subdir/*.ipynb']
self       = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_convert_full_qualified_name>
stderr     = b'[NbConvertApp] Searching [\'/home/tkloczko/.jupyter\', \'/home/tkloczko/.local/etc/jupyter\', \'/usr/etc/jupyter\', ...n one of: asciidoc, custom, html, latex, markdown, notebook, pdf, python, qtpdf, qtpng, rst, script, slides, webpdf?\n'
stdin      = None
stdout     = b''

tests/base.py:168: OSError
_____________________ TestNbConvertApp.test_post_processor _____________________

self = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_post_processor>

    def test_post_processor(self):
        """Do post processors work?"""
        with self.create_temp_cwd(["notebook1.ipynb"]):
>           out, err = self.nbconvert(
                "--log-level 0 --to python notebook1 --post tests.test_nbconvertapp.DummyPost"
            )

self       = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_post_processor>

tests/test_nbconvertapp.py:180:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_post_processor>
parameters = ['--log-level', '0', '--to', 'python', 'notebook1', '--post', ...]
ignore_return_code = False, stdin = None

    def nbconvert(self, parameters, ignore_return_code=False, stdin=None):
        """
        Run nbconvert as a shell command, listening for both Errors and
        non-zero return codes. Returns the tuple (stdout, stderr) of
        output produced during the nbconvert run.

        Parameters
        ----------
        parameters : str, list(str)
            List of parameters to pass to IPython.
        ignore_return_code : optional bool (default False)
            Throw an OSError if the return code
        """
        cmd = [sys.executable, "-m", "nbconvert"]
        if sys.platform == "win32":
            if isinstance(parameters, (str,)):
                cmd = " ".join(cmd) + " " + parameters
            else:
                cmd = " ".join(cmd + parameters)
        else:
            if isinstance(parameters, (str,)):
                parameters = shlex.split(parameters)
            cmd += parameters
        p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)  # noqa
        stdout, stderr = p.communicate(input=stdin)
        if not (p.returncode == 0 or ignore_return_code):
>           raise OSError(stderr.decode("utf8", "replace"))
E           OSError: Traceback (most recent call last):
E             File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
E               return _run_code(code, main_globals, None,
E             File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
E               exec(code, run_globals)
E             File "/home/tkloczko/rpmbuild/BUILDROOT/python-nbconvert-7.11.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/nbconvert/__main__.py", line 4, in <module>
E               main()
E             File "/usr/lib/python3.8/site-packages/jupyter_core/application.py", line 285, in launch_instance
E               return super().launch_instance(argv=argv, **kwargs)
E             File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 1052, in launch_instance
E               app.initialize(argv)
E             File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 117, in inner
E               return method(app, *args, **kwargs)
E             File "/home/tkloczko/rpmbuild/BUILDROOT/python-nbconvert-7.11.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 359, in initialize
E               super().initialize(argv)
E             File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 117, in inner
E               return method(app, *args, **kwargs)
E             File "/usr/lib/python3.8/site-packages/jupyter_core/application.py", line 256, in initialize
E               self.parse_command_line(argv)
E             File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 117, in inner
E               return method(app, *args, **kwargs)
E             File "/usr/lib/python3.8/site-packages/traitlets/config/application.py", line 886, in parse_command_line
E               self.update_config(self.cli_config)
E             File "/usr/lib/python3.8/site-packages/traitlets/config/configurable.py", line 241, in update_config
E               self._load_config(config)
E             File "/usr/lib/python3.8/site-packages/traitlets/config/configurable.py", line 211, in _load_config
E               warn(msg)
E             File "/usr/lib64/python3.8/contextlib.py", line 120, in __exit__
E               next(self.gen)
E             File "/usr/lib/python3.8/site-packages/traitlets/traitlets.py", line 1529, in hold_trait_notifications
E               self.notify_change(change)
E             File "/usr/lib/python3.8/site-packages/traitlets/traitlets.py", line 1544, in notify_change
E               return self._notify_observers(change)
E             File "/usr/lib/python3.8/site-packages/traitlets/traitlets.py", line 1591, in _notify_observers
E               c(event)
E             File "/home/tkloczko/rpmbuild/BUILDROOT/python-nbconvert-7.11.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 329, in _postprocessor_class_changed
E               self.postprocessor_factory = import_item(new)
E             File "/usr/lib/python3.8/site-packages/traitlets/utils/importstring.py", line 31, in import_item
E               module = __import__(package, fromlist=[obj])
E           ModuleNotFoundError: No module named 'tests'

cmd        = ['/usr/bin/python3', '-m', 'nbconvert', '--log-level', '0', '--to', ...]
ignore_return_code = False
p          = <subprocess.Popen object at 0x7fb9f953b850>
parameters = ['--log-level', '0', '--to', 'python', 'notebook1', '--post', ...]
self       = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_post_processor>
stderr     = b'Traceback (most recent call last):\n  File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main\n    re...31, in import_item\n    module = __import__(package, fromlist=[obj])\nModuleNotFoundError: No module named \'tests\'\n'
stdin      = None
stdout     = b''

tests/base.py:168: OSError
=============================== warnings summary ===============================
../../../../../usr/lib/python3.8/site-packages/jupyter_client/connect.py:22
  /usr/lib/python3.8/site-packages/jupyter_client/connect.py:22: 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, jupyter_runtime_dir, secure_write

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================= slowest 10 durations =============================
11.14s call     tests/exporters/test_latex.py::TestLatexExporter::test_very_long_cells
9.65s call     tests/test_nbconvertapp.py::TestNbConvertApp::test_allow_errors
8.47s call     tests/test_nbconvertapp.py::TestNbConvertApp::test_output_base
5.55s call     tests/test_nbconvertapp.py::TestNbConvertApp::test_errors_print_traceback
5.52s call     tests/test_nbconvertapp.py::TestNbConvertApp::test_execute_multiple_notebooks
4.32s call     tests/exporters/test_html.py::TestHTMLExporter::test_javascript_injection
4.15s call     tests/test_nbconvertapp.py::TestNbConvertApp::test_write_figures_to_custom_path
3.95s call     tests/test_nbconvertapp.py::TestNbConvertApp::test_spurious_cr
3.62s call     tests/test_nbconvertapp.py::TestNbConvertApp::test_no_prompt
3.59s call     tests/test_nbconvertapp.py::TestNbConvertApp::test_execute_widgets_from_nbconvert
=========================== short test summary info ============================
SKIPPED [1] tests/test_nbconvertapp.py:276: This test runs only if command 'xelatex' is installed
SKIPPED [1] tests/test_nbconvertapp.py:137: This test runs only if command 'xelatex' is installed
SKIPPED [1] tests/test_nbconvertapp.py:481: This test runs only if command 'xelatex' is installed
SKIPPED [1] tests/test_nbconvertapp.py:163: This test runs only if command 'xelatex' is installed
SKIPPED [1] tests/exporters/test_pdf.py:30: This test runs only if command 'xelatex' is installed
SKIPPED [1] tests/exporters/test_pdf.py:45: This test runs only if command 'xelatex' is installed
SKIPPED [1] tests/exporters/test_qtpdf.py:20: PyQtWebEngine not installed
SKIPPED [2] tests/exporters/base.py:28: PyQtWebEngine not installed
SKIPPED [1] tests/exporters/test_qtpng.py:23: PyQtWebEngine not installed
SKIPPED [1] tests/exporters/base.py:28: Playwright not installed
SKIPPED [1] tests/exporters/test_webpdf.py:46: Playwright not installed
SKIPPED [1] tests/exporters/test_webpdf.py:54: Playwright not installed
FAILED tests/test_nbconvertapp.py::TestNbConvertApp::test_convert_full_qualified_name - OSError: [NbConvertApp] Searching ['/home/tkloczko/.jupyter', '/home/tklocz...
FAILED tests/test_nbconvertapp.py::TestNbConvertApp::test_post_processor - OSError: Traceback (most recent call last):
= 2 failed, 303 passed, 13 skipped, 2 deselected, 1 warning in 166.10s (0:02:46) =

Here is list of installed modules in build env

Package                       Version
----------------------------- ---------
alabaster                     0.7.13
appdirs                       1.4.4
asttokens                     2.2.1
attrs                         23.1.0
Babel                         2.13.1
backcall                      0.2.0
beautifulsoup4                4.12.2
bleach                        6.1.0
build                         1.0.3
certifi                       2023.7.22
charset-normalizer            3.3.2
comm                          0.1.4
coverage                      7.3.2
cppclean                      0.13
cssselect                     1.2.0
debugpy                       1.8.0
decorator                     5.1.1
defusedxml                    0.7.1
distro                        1.8.0
docutils                      0.20.1
editables                     0.5
entrypoints                   0.4
exceptiongroup                1.1.3
executing                     2.0.1
fastjsonschema                2.18.0
flaky                         3.7.0
gpg                           1.23.0
hatchling                     1.18.0
html5lib                      1.1
idna                          3.4
imagesize                     1.4.1
importlib-metadata            6.8.0
importlib-resources           6.1.0
iniconfig                     2.0.0
installer                     0.7.0
ipykernel                     6.26.0
ipython                       8.12.0
ipywidgets                    8.0.3
jedi                          0.19.1
Jinja2                        3.1.2
jsonschema                    4.19.1
jsonschema-specifications     2023.7.1
jupyter_client                8.5.0
jupyter_core                  5.3.1
jupyterlab-pygments           0.1.2
jupyterlab-widgets            3.0.8
lxml                          4.9.3
markdown-it-py                3.0.0
MarkupSafe                    2.1.3
matplotlib-inline             0.1.6
mdit-py-plugins               0.4.0
mdurl                         0.1.2
mistune                       2.0.5
myst-parser                   2.0.0
nbclient                      0.8.0
nbformat                      5.9.2
nest-asyncio                  1.5.8
numpy                         1.24.4
olefile                       0.46
packaging                     23.2
pandocfilters                 1.5.0
parso                         0.8.3
pathspec                      0.11.2
pexpect                       4.8.0
pickleshare                   0.7.5
Pillow                        10.1.0
pkgutil_resolve_name          1.3.10
platformdirs                  3.11.0
pluggy                        1.3.0
prompt-toolkit                3.0.39
psutil                        5.9.5
ptyprocess                    0.7.0
pure-eval                     0.2.2
pyee                          9.0.4
Pygments                      2.16.1
pyppeteer                     1.0.1
pyproject_hooks               1.0.0
pytest                        7.4.3
pytest-cov                    4.1.0
pytest-dependency             0.5.1
python-dateutil               2.8.2
pytz                          2023.3
PyYAML                        6.0.1
pyzmq                         25.1.1
referencing                   0.30.2
requests                      2.31.0
rpds-py                       0.12.0
scour                         0.38.2
six                           1.16.0
snowballstemmer               2.2.0
soupsieve                     2.5
Sphinx                        7.1.2
sphinx-rtd-theme              1.2.2
sphinxcontrib-applehelp       1.0.4
sphinxcontrib-devhelp         1.0.5
sphinxcontrib_github_alt      1.2
sphinxcontrib-htmlhelp        2.0.4
sphinxcontrib-jquery          4.1
sphinxcontrib-jsmath          1.0.1
sphinxcontrib-qthelp          1.0.3
sphinxcontrib-serializinghtml 1.1.9
stack-data                    0.6.3
testpath                      0.6.0
tinycss2                      1.2.1
tomli                         2.0.1
tornado                       6.3.3
tqdm                          4.66.1
traitlets                     5.11.2
trove-classifiers             2023.11.2
typing_extensions             4.8.0
urllib3                       1.26.18
wcwidth                       0.2.9
webencodings                  0.5.1
websockets                    12.0
wheel                         0.41.3
widgetsnbextension            4.0.9
zipp                          3.17.0
@ivanov ivanov added the bug label Feb 8, 2024
@ivanov
Copy link
Member

ivanov commented Feb 8, 2024

Thanks for the report, confirming that I see the same on 7.16.0, running it on Debian and FreeBSD

FAILED tests/test_nbconvertapp.py::TestNbConvertApp::test_convert_full_qualified_name - OSError: [NbConvertApp] Searching ['/root/.jupyter', '/root/.local/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config fil
es
FAILED tests/test_nbconvertapp.py::TestNbConvertApp::test_post_processor - OSError: Traceback (most recent call last):
===================================================================================================================== test session starts ===================================================================================================================== platform freebsd14 -- Python 3.9.18, pytest-7.4.3, pluggy-1.3.0 -- /usr/local/bin/python3.9 cachedir: .pytest_cache rootdir: /home/pi/code/plgrnd/freebsd/ports/devel/py-nbconvert/work-py39/nbconvert-7.16.0 configfile: pyproject.toml testpaths: tests/ plugins: flaky-3.7.0, anyio-4.2.0 collected 321 items

tests/test_nbconvertapp.py::TestNbConvertApp::test_convert_full_qualified_name FAILED [ 2%]
tests/test_nbconvertapp.py::TestNbConvertApp::test_post_processor FAILED [ 12%]

========================================================================================================================== FAILURES ===========================================================================================================================
______________________________________________________________________________________________________ TestNbConvertApp.test_convert_full_qualified_name ______________________________________________________________________________________________________

self = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_convert_full_qualified_name>

def test_convert_full_qualified_name(self):
    """
    Test that nbconvert can convert file using a full qualified name for a
    package, import and use it.
    """
    with self.create_temp_cwd():
        self.copy_files_to(["notebook*.ipynb"], "subdir")
      self.nbconvert(
            "--to tests.fake_exporters.MyExporter --log-level 0 "
            + os.path.join("subdir", "*.ipynb")
        )

tests/test_nbconvertapp.py:80:


self = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_convert_full_qualified_name>, parameters = ['--to', 'tests.fake_exporters.MyExporter', '--log-level', '0', 'subdir/*.ipynb'], ignore_return_code = False, stdin = None

def nbconvert(self, parameters, ignore_return_code=False, stdin=None):
    """
    Run nbconvert as a shell command, listening for both Errors and
    non-zero return codes. Returns the tuple (stdout, stderr) of
    output produced during the nbconvert run.

    Parameters
    ----------
    parameters : str, list(str)
        List of parameters to pass to IPython.
    ignore_return_code : optional bool (default False)
        Throw an OSError if the return code
    """
    cmd = [sys.executable, "-m", "nbconvert"]
    if sys.platform == "win32":
        if isinstance(parameters, (str,)):
            cmd = " ".join(cmd) + " " + parameters
        else:
            cmd = " ".join(cmd + parameters)
    else:
        if isinstance(parameters, (str,)):
            parameters = shlex.split(parameters)
        cmd += parameters
    p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)  # noqa
    stdout, stderr = p.communicate(input=stdin)
    if not (p.returncode == 0 or ignore_return_code):
      raise OSError(stderr.decode("utf8", "replace"))

E OSError: [NbConvertApp] Searching ['/home/pi/code/plgrnd/freebsd/ports/devel/py-nbconvert/work-py39/.jupyter', '/home/pi/code/plgrnd/freebsd/ports/devel/py-nbconvert/work-py39/.local/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
E [NbConvertApp] Looking for jupyter_config in /etc/jupyter
E [NbConvertApp] Looking for jupyter_config in /usr/local/etc/jupyter
E [NbConvertApp] Looking for jupyter_config in /home/pi/code/plgrnd/freebsd/ports/devel/py-nbconvert/work-py39/.local/etc/jupyter
E [NbConvertApp] Looking for jupyter_config in /home/pi/code/plgrnd/freebsd/ports/devel/py-nbconvert/work-py39/.jupyter
E [NbConvertApp] Looking for jupyter_nbconvert_config in /etc/jupyter
E [NbConvertApp] Looking for jupyter_nbconvert_config in /usr/local/etc/jupyter
E [NbConvertApp] Looking for jupyter_nbconvert_config in /home/pi/code/plgrnd/freebsd/ports/devel/py-nbconvert/work-py39/.local/etc/jupyter
E [NbConvertApp] Looking for jupyter_nbconvert_config in /home/pi/code/plgrnd/freebsd/ports/devel/py-nbconvert/work-py39/.jupyter
E [NbConvertApp] Looping through config variables with prefix "JUPYTER_NBCONVERT"
E [NbConvertApp] ERROR | Error importing tests.fake_exporters.MyExporter
E Traceback (most recent call last):
E File "/usr/local/lib/python3.9/site-packages/nbconvert/exporters/base.py", line 115, in get_exporter
E exporter = import_item(name)
E File "/usr/local/lib/python3.9/site-packages/traitlets/utils/importstring.py", line 33, in import_item
E module = import(package, fromlist=[obj])
E ModuleNotFoundError: No module named 'tests'
E Traceback (most recent call last):
E File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
E return _run_code(code, main_globals, None,
E File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
E exec(code, run_globals)
E File "/usr/local/lib/python3.9/site-packages/nbconvert/main.py", line 4, in
E main()
E File "/usr/local/lib/python3.9/site-packages/jupyter_core/application.py", line 281, in launch_instance
E super().launch_instance(argv=argv, **kwargs)
E File "/usr/local/lib/python3.9/site-packages/traitlets/config/application.py", line 1075, in launch_instance
E app.start()
E File "/usr/local/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 420, in start
E self.convert_notebooks()
E File "/usr/local/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 585, in convert_notebooks
E cls = get_exporter(self.export_format)
E File "/usr/local/lib/python3.9/site-packages/nbconvert/exporters/base.py", line 126, in get_exporter
E raise ExporterNameError(msg)
E nbconvert.exporters.base.ExporterNameError: Unknown exporter "tests.fake_exporters.MyExporter", did you mean one of: asciidoc, custom, html, latex, markdown, notebook, pdf, python, qtpdf, qtpng, rst, script, slides, webpdf?

tests/base.py:168: OSError
____________________________________________________________________________________________________________ TestNbConvertApp.test_post_processor _____________________________________________________________________________________________________________

self = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_post_processor>

def test_post_processor(self):
    """Do post processors work?"""
    with self.create_temp_cwd(["notebook1.ipynb"]):
      out, err = self.nbconvert(
            "--log-level 0 --to python notebook1 --post tests.test_nbconvertapp.DummyPost"
        )

tests/test_nbconvertapp.py:180:


self = <tests.test_nbconvertapp.TestNbConvertApp testMethod=test_post_processor>, parameters = ['--log-level', '0', '--to', 'python', 'notebook1', '--post', ...], ignore_return_code = False, stdin = None

def nbconvert(self, parameters, ignore_return_code=False, stdin=None):
    """
    Run nbconvert as a shell command, listening for both Errors and
    non-zero return codes. Returns the tuple (stdout, stderr) of
    output produced during the nbconvert run.

    Parameters
    ----------
    parameters : str, list(str)
        List of parameters to pass to IPython.
    ignore_return_code : optional bool (default False)
        Throw an OSError if the return code
    """
    cmd = [sys.executable, "-m", "nbconvert"]
    if sys.platform == "win32":
        if isinstance(parameters, (str,)):
            cmd = " ".join(cmd) + " " + parameters
        else:
            cmd = " ".join(cmd + parameters)
    else:
        if isinstance(parameters, (str,)):
            parameters = shlex.split(parameters)
        cmd += parameters
    p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)  # noqa
    stdout, stderr = p.communicate(input=stdin)
    if not (p.returncode == 0 or ignore_return_code):
      raise OSError(stderr.decode("utf8", "replace"))

E OSError: Traceback (most recent call last):
E File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
E return _run_code(code, main_globals, None,
E File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
E exec(code, run_globals)
E File "/usr/local/lib/python3.9/site-packages/nbconvert/main.py", line 4, in
E main()
E File "/usr/local/lib/python3.9/site-packages/jupyter_core/application.py", line 281, in launch_instance
E super().launch_instance(argv=argv, **kwargs)
E File "/usr/local/lib/python3.9/site-packages/traitlets/config/application.py", line 1074, in launch_instance
E app.initialize(argv)
E File "/usr/local/lib/python3.9/site-packages/traitlets/config/application.py", line 118, in inner
E return method(app, *args, **kwargs)
E File "/usr/local/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 365, in initialize
E super().initialize(argv)
E File "/usr/local/lib/python3.9/site-packages/traitlets/config/application.py", line 118, in inner
E return method(app, *args, **kwargs)
E File "/usr/local/lib/python3.9/site-packages/jupyter_core/application.py", line 252, in initialize
E self.parse_command_line(argv)
E File "/usr/local/lib/python3.9/site-packages/traitlets/config/application.py", line 118, in inner
E return method(app, *args, **kwargs)
E File "/usr/local/lib/python3.9/site-packages/traitlets/config/application.py", line 886, in parse_command_line
E self.update_config(self.cli_config)
E File "/usr/local/lib/python3.9/site-packages/traitlets/config/configurable.py", line 244, in update_config
E self._load_config(config)
E File "/usr/local/lib/python3.9/site-packages/traitlets/config/configurable.py", line 214, in _load_config
E warn(msg)
E File "/usr/local/lib/python3.9/contextlib.py", line 126, in exit
E next(self.gen)
E File "/usr/local/lib/python3.9/site-packages/traitlets/traitlets.py", line 1510, in hold_trait_notifications
E self.notify_change(change)
E File "/usr/local/lib/python3.9/site-packages/traitlets/traitlets.py", line 1525, in notify_change
E return self._notify_observers(change)
E File "/usr/local/lib/python3.9/site-packages/traitlets/traitlets.py", line 1568, in _notify_observers
E c(event)
E File "/usr/local/lib/python3.9/site-packages/nbconvert/nbconvertapp.py", line 335, in _postprocessor_class_changed
E self.postprocessor_factory = import_item(new)
E File "/usr/local/lib/python3.9/site-packages/traitlets/utils/importstring.py", line 33, in import_item
E module = import(package, fromlist=[obj])
E ModuleNotFoundError: No module named 'tests'

tests/base.py:168: OSError
============================================================================================== 2 failed, 277 passed, 42 skipped, 1 warning in 142.79s (0:02:22) ===============================================================================================
*** Error code 1

Stop.

@ivanov ivanov changed the title 7.11.0: pytest is failing in two tests/test_nbconvertapp.py units pytest is failing in two tests/test_nbconvertapp.py units (7.11.0 - 7.16.0) Feb 8, 2024
@ivanov
Copy link
Member

ivanov commented Feb 9, 2024

@kloczek #2108 has the fix for these two failing tests

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants