Open
Description
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>
- run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
Here is pytest output:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sphinxcontrib-kroki-1.3.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sphinxcontrib-kroki-1.3.0-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
libraries: Sphinx-5.1.1, docutils-0.18.1
base tempdir: /tmp/pytest-of-tkloczko/pytest-913
rootdir: /home/tkloczko/rpmbuild/BUILD/kroki-1.3.0, configfile: pyproject.toml
collected 1 item
tests/test_kroki.py F [100%]
================================================================================= FAILURES =================================================================================
_____________________________________________________________________________ test_kroki_html ______________________________________________________________________________
builder = <sphinx.builders.html.StandaloneHTMLBuilder object at 0x7f4400c59d90>, diagram_type = 'mermaid', diagram_source = 'graph TD\n A[ Anyone ]', output_format = 'svg'
diagram_options = {}, prefix = 'kroki'
def render_kroki(
builder: Builder,
diagram_type: str,
diagram_source: str,
output_format: str,
diagram_options: Dict[str, Any] = {},
prefix: str = "kroki",
) -> Path:
kroki_url: str = builder.config.kroki_url
payload: Dict[str, Union[str, Dict]] = {
"diagram_source": diagram_source,
"diagram_type": diagram_type,
"diagram_options": diagram_options,
"output_format": output_format,
}
hashkey = (str(kroki_url) + str(payload)).encode()
fname = "%s-%s.%s" % (prefix, sha1(hashkey).hexdigest(), output_format)
outfn = Path(builder.outdir).joinpath(builder.imagedir, fname)
if outfn.is_file():
return outfn
try:
outfn.parent.mkdir(parents=True, exist_ok=True)
response = requests.post(kroki_url, json=payload, stream=True)
> response.raise_for_status()
../../BUILDROOT/python-sphinxcontrib-kroki-1.3.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/sphinxcontrib/kroki/kroki.py:269:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Response [500]>
def raise_for_status(self):
"""Raises :class:`HTTPError`, if one occurred."""
http_error_msg = ""
if isinstance(self.reason, bytes):
# We attempt to decode utf-8 first because some servers
# choose to localize their reason strings. If the string
# isn't utf-8, we fall back to iso-8859-1 for all other
# encodings. (See PR #3538)
try:
reason = self.reason.decode("utf-8")
except UnicodeDecodeError:
reason = self.reason.decode("iso-8859-1")
else:
reason = self.reason
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
)
elif 500 <= self.status_code < 600:
http_error_msg = (
f"{self.status_code} Server Error: {reason} for url: {self.url}"
)
if http_error_msg:
> raise HTTPError(http_error_msg, response=self)
E requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://kroki.io/
/usr/lib/python3.8/site-packages/requests/models.py:1021: HTTPError
The above exception was the direct cause of the following exception:
self = <sphinxcontrib.kroki.transform.KrokiToImageTransform object at 0x7f4400c5ff10>, node = <kroki: >, prefix = 'kroki'
def render(self, node: kroki, prefix: str = "kroki") -> Path:
builder = self.app.builder
output_format = self.output_format(node)
diagram_type = node["type"]
diagram_source = node["source"]
diagram_options = node["options"] if "options" in node else {}
try:
> out = render_kroki(
builder,
diagram_type,
diagram_source,
output_format,
diagram_options,
prefix,
)
../../BUILDROOT/python-sphinxcontrib-kroki-1.3.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/sphinxcontrib/kroki/transform.py:44:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
builder = <sphinx.builders.html.StandaloneHTMLBuilder object at 0x7f4400c59d90>, diagram_type = 'mermaid', diagram_source = 'graph TD\n A[ Anyone ]', output_format = 'svg'
diagram_options = {}, prefix = 'kroki'
def render_kroki(
builder: Builder,
diagram_type: str,
diagram_source: str,
output_format: str,
diagram_options: Dict[str, Any] = {},
prefix: str = "kroki",
) -> Path:
kroki_url: str = builder.config.kroki_url
payload: Dict[str, Union[str, Dict]] = {
"diagram_source": diagram_source,
"diagram_type": diagram_type,
"diagram_options": diagram_options,
"output_format": output_format,
}
hashkey = (str(kroki_url) + str(payload)).encode()
fname = "%s-%s.%s" % (prefix, sha1(hashkey).hexdigest(), output_format)
outfn = Path(builder.outdir).joinpath(builder.imagedir, fname)
if outfn.is_file():
return outfn
try:
outfn.parent.mkdir(parents=True, exist_ok=True)
response = requests.post(kroki_url, json=payload, stream=True)
response.raise_for_status()
with outfn.open(mode="wb") as f:
for chunk in response.iter_content(chunk_size=128):
f.write(chunk)
return outfn
except requests.exceptions.RequestException as e:
> raise KrokiError(__("kroki did not produce a diagram")) from e
E sphinxcontrib.kroki.kroki.KrokiError: kroki did not produce a diagram
../../BUILDROOT/python-sphinxcontrib-kroki-1.3.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/sphinxcontrib/kroki/kroki.py:276: KrokiError
The above exception was the direct cause of the following exception:
app = <SphinxTestApp buildername='html'>, status = <_io.StringIO object at 0x7f4401baf3a0>, warning = <_io.StringIO object at 0x7f4401baf430>
@pytest.mark.sphinx(
"html", testroot="kroki", confoverrides={"master_doc": "index"}
)
def test_kroki_html(app, status, warning):
> content = get_content(app)
tests/test_kroki.py:24:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_kroki.py:14: in get_content
app.builder.build_all()
/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py:265: in build_all
self.build(None, summary=__('all source files'), method='all')
/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py:317: in build
updated_docnames = set(self.read())
/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py:424: in read
self._read_serial(docnames)
/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py:445: in _read_serial
self.read_doc(docname)
/usr/lib/python3.8/site-packages/sphinx/builders/__init__.py:498: in read_doc
publisher.publish()
/usr/lib/python3.8/site-packages/docutils/core.py:219: in publish
self.apply_transforms()
/usr/lib/python3.8/site-packages/docutils/core.py:200: in apply_transforms
self.document.transformer.apply_transforms()
/usr/lib/python3.8/site-packages/sphinx/transforms/__init__.py:80: in apply_transforms
super().apply_transforms()
/usr/lib/python3.8/site-packages/docutils/transforms/__init__.py:171: in apply_transforms
transform.apply(**kwargs)
../../BUILDROOT/python-sphinxcontrib-kroki-1.3.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/sphinxcontrib/kroki/transform.py:26: in apply
out = self.render(node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <sphinxcontrib.kroki.transform.KrokiToImageTransform object at 0x7f4400c5ff10>, node = <kroki: >, prefix = 'kroki'
def render(self, node: kroki, prefix: str = "kroki") -> Path:
builder = self.app.builder
output_format = self.output_format(node)
diagram_type = node["type"]
diagram_source = node["source"]
diagram_options = node["options"] if "options" in node else {}
try:
out = render_kroki(
builder,
diagram_type,
diagram_source,
output_format,
diagram_options,
prefix,
)
except KrokiError as exc:
logger.warning(
__("kroki %s diagram (%s) with source %r: %s"),
diagram_type,
output_format,
diagram_source,
exc,
)
> raise SkipNode from exc
E docutils.nodes.SkipNode
../../BUILDROOT/python-sphinxcontrib-kroki-1.3.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/sphinxcontrib/kroki/transform.py:60: SkipNode
------------------------------------------------------------------------- Captured stdout teardown -------------------------------------------------------------------------
# testroot: root
# builder: html
# srcdir: /tmp/pytest-of-tkloczko/pytest-913/kroki
# outdir: /tmp/pytest-of-tkloczko/pytest-913/kroki/_build/html
# status:
Running Sphinx v5.1.1
building [html]: all source files
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index
# warning:
WARNING: kroki mermaid diagram (svg) with source 'graph TD\n A[ Anyone ]': kroki did not produce a diagram
============================================================================= warnings summary =============================================================================
tests/test_kroki.py::test_kroki_html
/home/tkloczko/rpmbuild/BUILDROOT/python-sphinxcontrib-kroki-1.3.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/sphinxcontrib/kroki/transform.py:17: PendingDeprecationWarning: nodes.Node.traverse() is obsoleted by Node.findall().
for node in self.document.traverse(kroki):
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= short test summary info ==========================================================================
FAILED tests/test_kroki.py::test_kroki_html - docutils.nodes.SkipNode
======================================================================= 1 failed, 1 warning in 0.91s =======================================================================
Here is list of modules installed in build env:
Package Version
----------------------------- -----------------
alabaster 0.7.12
attrs 22.1.0
Babel 2.10.2
Brlapi 0.8.3
build 0.8.0
charset-normalizer 2.1.0
codespell 2.1.0
cycler 0.11.0
distro 1.7.0
docutils 0.18.1
extras 1.0.0
fixtures 4.0.0
flit_core 3.7.1
fonttools 4.37.1
gpg 1.17.1-unknown
idna 3.3
imagesize 1.4.1
importlib-metadata 4.12.0
iniconfig 1.1.1
Jinja2 3.1.1
kiwisolver 1.4.4
libcomps 0.1.18
louis 3.22.0
MarkupSafe 2.1.1
matplotlib 3.5.3
numpy 1.23.1
olefile 0.46
packaging 21.3
pbr 5.9.0
pep517 0.12.0
Pillow 9.2.0
pip 22.2.1
pluggy 1.0.0
py 1.11.0
Pygments 2.13.0
PyGObject 3.42.2
pyparsing 3.0.9
pytest 7.1.2
python-dateutil 2.8.2
pytz 2022.1
PyYAML 6.0
requests 2.28.1
rpm 4.17.0
setuptools 65.3.0
six 1.16.0
snowballstemmer 2.2.0
Sphinx 5.1.1
sphinxcontrib-applehelp 1.0.2.dev20220730
sphinxcontrib-devhelp 1.0.2.dev20220730
sphinxcontrib-htmlhelp 2.0.0
sphinxcontrib-jsmath 1.0.1.dev20220730
sphinxcontrib-qthelp 1.0.3.dev20220730
sphinxcontrib-serializinghtml 1.1.5
testtools 2.5.0
tomli 2.0.1
urllib3 1.26.12
wheel 0.37.1
zipp 3.8.1
Activity