executablebooks / sphinx-thebe

A Sphinx extension to convert static code into interactive code cells with Jupyter, Thebe, and Binder.
https://sphinx-thebe.readthedocs.io/en/latest/
MIT License
29 stars 15 forks source link

0.1.2: pytest is failing #56

Closed kloczek closed 1 year ago

kloczek commented 2 years ago

Describe the bug

Looks like pytest is failing.

Here is pytest output:

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-thebe-0.1.2-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphinx-thebe-0.1.2-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra =========================================================================== test session starts ============================================================================ platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/sphinx-thebe-0.1.2 plugins: datadir-1.3.1, regressions-2.3.1 collected 2 items tests/test_build.py FF [100%] ================================================================================= FAILURES ================================================================================= ____________________________________________________________________________ test_sphinx_thebe _____________________________________________________________________________ file_regression = sphinx_build = .SphinxBuild object at 0x7f3346aaa850> def test_sphinx_thebe(file_regression, sphinx_build): """Test building with thebe.""" sphinx_build.copy() # Basic build with defaults > sphinx_build.build() tests/test_build.py:51: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_build.py:37: in build run(self.cmd_base + cmd, cwd=self.path_tmp_docs, check=True) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ input = None, capture_output = False, timeout = None, check = True, popenargs = (['sphinx-build', '.', '_build/html', '-a', '-W'],) kwargs = {'cwd': PosixPath('/tmp/pytest-of-tkloczko/pytest-345/build0/docs')}, process = , stdout = None, stderr = None retcode = 2 def run(*popenargs, input=None, capture_output=False, timeout=None, check=False, **kwargs): """Run command with arguments and return a CompletedProcess instance. The returned instance will have attributes args, returncode, stdout and stderr. By default, stdout and stderr are not captured, and those attributes will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them. If check is True and the exit code was non-zero, it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute, and output & stderr attributes if those streams were captured. If timeout is given, and the process takes too long, a TimeoutExpired exception will be raised. There is an optional argument "input", allowing you to pass bytes or a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it will be used internally. By default, all communication is in bytes, and therefore any "input" should be bytes, and the stdout and stderr will be bytes. If in text mode, any "input" should be a string, and stdout and stderr will be strings decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. The other arguments are the same as for the Popen constructor. """ if input is not None: if kwargs.get('stdin') is not None: raise ValueError('stdin and input arguments may not both be used.') kwargs['stdin'] = PIPE if capture_output: if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None: raise ValueError('stdout and stderr arguments may not be used ' 'with capture_output.') kwargs['stdout'] = PIPE kwargs['stderr'] = PIPE with Popen(*popenargs, **kwargs) as process: try: stdout, stderr = process.communicate(input, timeout=timeout) except TimeoutExpired as exc: process.kill() if _mswindows: # Windows accumulates the output in a single blocking # read() call run on child threads, with the timeout # being done in a join() on those threads. communicate() # _after_ kill() is required to collect that and add it # to the exception. exc.stdout, exc.stderr = process.communicate() else: # POSIX _communicate already populated the output so # far into the TimeoutExpired exception. process.wait() raise except: # Including KeyboardInterrupt, communicate handled that. process.kill() # We don't call process.wait() as .__exit__ does that for us. raise retcode = process.poll() if check and retcode: > raise CalledProcessError(retcode, process.args, output=stdout, stderr=stderr) E subprocess.CalledProcessError: Command '['sphinx-build', '.', '_build/html', '-a', '-W']' returned non-zero exit status 2. /usr/lib64/python3.8/subprocess.py:516: CalledProcessError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- Running Sphinx v5.0.2 --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- Warning, treated as error: Invalid configuration value found: 'language = None'. Update your configuration to a valid langauge code. Falling back to 'en' (English). ______________________________________________________________________________ test_lazy_load ______________________________________________________________________________ file_regression = sphinx_build = .SphinxBuild object at 0x7f3346aaa850> def test_lazy_load(file_regression, sphinx_build): """Test building with thebe.""" sphinx_build.copy() url = "https://unpkg.com/thebe@0.8.2/lib/index.js" # URL to search for # Thebe JS should not be loaded by default (is loaded lazily) > sphinx_build.build() tests/test_build.py:97: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_build.py:37: in build run(self.cmd_base + cmd, cwd=self.path_tmp_docs, check=True) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ input = None, capture_output = False, timeout = None, check = True, popenargs = (['sphinx-build', '.', '_build/html', '-a', '-W'],) kwargs = {'cwd': PosixPath('/tmp/pytest-of-tkloczko/pytest-345/build0/docs')}, process = , stdout = None, stderr = None retcode = 2 def run(*popenargs, input=None, capture_output=False, timeout=None, check=False, **kwargs): """Run command with arguments and return a CompletedProcess instance. The returned instance will have attributes args, returncode, stdout and stderr. By default, stdout and stderr are not captured, and those attributes will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them. If check is True and the exit code was non-zero, it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute, and output & stderr attributes if those streams were captured. If timeout is given, and the process takes too long, a TimeoutExpired exception will be raised. There is an optional argument "input", allowing you to pass bytes or a string to the subprocess's stdin. If you use this argument you may not also use the Popen constructor's "stdin" argument, as it will be used internally. By default, all communication is in bytes, and therefore any "input" should be bytes, and the stdout and stderr will be bytes. If in text mode, any "input" should be a string, and stdout and stderr will be strings decoded according to locale encoding, or by "encoding" if set. Text mode is triggered by setting any of text, encoding, errors or universal_newlines. The other arguments are the same as for the Popen constructor. """ if input is not None: if kwargs.get('stdin') is not None: raise ValueError('stdin and input arguments may not both be used.') kwargs['stdin'] = PIPE if capture_output: if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None: raise ValueError('stdout and stderr arguments may not be used ' 'with capture_output.') kwargs['stdout'] = PIPE kwargs['stderr'] = PIPE with Popen(*popenargs, **kwargs) as process: try: stdout, stderr = process.communicate(input, timeout=timeout) except TimeoutExpired as exc: process.kill() if _mswindows: # Windows accumulates the output in a single blocking # read() call run on child threads, with the timeout # being done in a join() on those threads. communicate() # _after_ kill() is required to collect that and add it # to the exception. exc.stdout, exc.stderr = process.communicate() else: # POSIX _communicate already populated the output so # far into the TimeoutExpired exception. process.wait() raise except: # Including KeyboardInterrupt, communicate handled that. process.kill() # We don't call process.wait() as .__exit__ does that for us. raise retcode = process.poll() if check and retcode: > raise CalledProcessError(retcode, process.args, output=stdout, stderr=stderr) E subprocess.CalledProcessError: Command '['sphinx-build', '.', '_build/html', '-a', '-W']' returned non-zero exit status 2. /usr/lib64/python3.8/subprocess.py:516: CalledProcessError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- Running Sphinx v5.0.2 --------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- Warning, treated as error: Invalid configuration value found: 'language = None'. Update your configuration to a valid langauge code. Falling back to 'en' (English). ========================================================================= short test summary info ========================================================================== FAILED tests/test_build.py::test_sphinx_thebe - subprocess.CalledProcessError: Command '['sphinx-build', '.', '_build/html', '-a', '-W']' returned non-zero exit status 2. FAILED tests/test_build.py::test_lazy_load - subprocess.CalledProcessError: Command '['sphinx-build', '.', '_build/html', '-a', '-W']' returned non-zero exit status 2. ============================================================================ 2 failed in 0.85s ============================================================================= /usr/lib/python3.8/site-packages/_pytest/pathlib.py:79: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-9e9ac49d-faf6-4aec-ba6c-fcc0dfdcb061/test_rmtree_errorhandler_rerai0 : [Errno 39] Directory not empty: 'test_rmtree_errorhandler_rerai0' warnings.warn( /usr/lib/python3.8/site-packages/_pytest/pathlib.py:79: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-9e9ac49d-faf6-4aec-ba6c-fcc0dfdcb061/test_rmtree_errorhandler_reado0 : [Errno 39] Directory not empty: 'test_rmtree_errorhandler_reado0' warnings.warn( /usr/lib/python3.8/site-packages/_pytest/pathlib.py:79: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-9e9ac49d-faf6-4aec-ba6c-fcc0dfdcb061/test_safe_delete_no_perms0 : [Errno 39] Directory not empty: 'test_safe_delete_no_perms0' warnings.warn( /usr/lib/python3.8/site-packages/_pytest/pathlib.py:79: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-9e9ac49d-faf6-4aec-ba6c-fcc0dfdcb061/test_safe_set_no_perms0 : [Errno 39] Directory not empty: 'test_safe_set_no_perms0' warnings.warn( /usr/lib/python3.8/site-packages/_pytest/pathlib.py:79: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-9e9ac49d-faf6-4aec-ba6c-fcc0dfdcb061/test_safe_get_no_perms0 : [Errno 39] Directory not empty: 'test_safe_get_no_perms0' warnings.warn( /usr/lib/python3.8/site-packages/_pytest/pathlib.py:79: PytestWarning: (rm_rf) error removing /tmp/pytest-of-tkloczko/garbage-9e9ac49d-faf6-4aec-ba6c-fcc0dfdcb061 : [Errno 39] Directory not empty: '/tmp/pytest-of-tkloczko/garbage-9e9ac49d-faf6-4aec-ba6c-fcc0dfdcb061' warnings.warn( ```

Reproduce the bug

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.

List your environment

Package Version


ablog 0.10.26 alabaster 0.7.12 appdirs 1.4.4 asttokens 2.0.5 attrs 22.1.0.dev0 Babel 2.10.2 backcall 0.2.0 beautifulsoup4 4.10.0 Brlapi 0.8.3 build 0.8.0 charset-normalizer 2.1.0 click 8.1.2 codespell 2.1.0 commonmark 0.9.1 cssselect 1.1.0 cycler 0.11.0 debugpy 1.6.2 decorator 5.1.1 distro 1.7.0 docutils 0.17.1 entrypoints 0.4 executing 0.8.3 extended-project 1.2.3 extras 1.0.0 fastjsonschema 2.15.3 feedgen 0.9.0 fixtures 4.0.0 fonttools 4.34.4 gpg 1.17.1-unknown greenlet 1.1.2 html2text 2020.1.16 idna 3.3 imagesize 1.4.1 importlib-metadata 4.12.0 importlib-resources 5.8.0 iniconfig 1.1.1 invoke 1.7.0 ipykernel 6.15.1 ipython 8.4.0 jedi 0.18.1 Jinja2 3.1.1 jsonschema 4.7.2 jupyter-cache 0.5.0 jupyter-client 7.3.4 jupyter-core 4.11.1 kiwisolver 1.4.4 libcomps 0.1.18 louis 3.22.0 lxml 4.9.1 markdown-it-py 2.1.0 MarkupSafe 2.1.1 matplotlib 3.5.2 matplotlib-inline 0.1.3 mdit-py-plugins 0.3.0 mdurl 0.1.1 metaextract 1.0.8 myst-nb 0.15.0 myst-parser 0.17.2 nbclient 0.6.6 nbformat 5.4.0 nest-asyncio 1.5.5 nodeenv 1.7.0 numpy 1.23.1 numpydoc 1.4.0 olefile 0.46 packaging 21.3 parso 0.8.3 pbr 5.8.1 pep517 0.12.0 pep621 0.4.0 pexpect 4.8.0 pickleshare 0.7.5 Pillow 9.2.0 pip 22.0.4 pluggy 1.0.0 prompt-toolkit 3.0.29 psutil 5.9.0 ptyprocess 0.7.0 pure-eval 0.2.2 py 1.11.0 py2pack 0.8.7 Pygments 2.12.0 PyGObject 3.42.1 pyparsing 3.0.9 pypi-search 1.2.1 pyrsistent 0.18.1 pytest 7.1.2 pytest-datadir 1.3.1 pytest-regressions 2.3.1 python-dateutil 2.8.2 pytz 2022.1 PyYAML 6.0 pyzmq 23.2.0 requests 2.28.1 rich 12.5.0 rpm 4.17.0 scour 0.38.2 setuptools 63.2.0 simple-project 1.2.3 six 1.16.0 snowballstemmer 2.2.0 soupsieve 2.3.2.post1 Sphinx 5.0.2 sphinx-copybutton 0.5.0 sphinx_design 0.2.0 sphinx-examples 0.0.5 sphinx-panels 0.6.0 sphinx-tabs 3.4.1 sphinx-theme-builder 0.2.0a14 sphinx-togglebutton 0.3.2 sphinxcontrib-applehelp 1.0.2.dev20220714 sphinxcontrib-devhelp 1.0.2.dev20220714 sphinxcontrib-htmlhelp 2.0.0 sphinxcontrib-jsmath 1.0.1.dev20220712 sphinxcontrib-qthelp 1.0.3.dev20220712 sphinxcontrib-serializinghtml 1.1.5 sphinxcontrib-youtube 1.1.0 SQLAlchemy 1.4.39.dev0 stack-data 0.3.0 tabulate 0.8.9 testtools 2.5.0 tomli 2.0.1 tornado 6.1 traitlets 5.3.0 typing_extensions 4.2.0 urllib3 1.26.9 watchdog 2.1.9 wcwidth 0.2.5 wheel 0.37.1 zipp 3.8.1

choldgraf commented 1 year ago

We just merged in support for Sphinx 5 and 6 in the following PR, so closing this.