From 75ae73cb1f74c0de74296d21bf108440e41bd2d6 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Sat, 14 Sep 2024 22:34:33 -0400 Subject: [PATCH] chore: raise from e instead of putting e in exception message --- ocdsindex/extract.py | 2 +- tests/test_extract.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ocdsindex/extract.py b/ocdsindex/extract.py index 34e7a54..bc91a18 100644 --- a/ocdsindex/extract.py +++ b/ocdsindex/extract.py @@ -66,7 +66,7 @@ def extract_sphinx(url, tree): section_title = section.xpath("h1|h2|h3|h4|h5|h6")[0].text_content().rstrip("ΒΆ") except IndexError as e: logger.exception("No heading found\n%s", lxml.html.tostring(section).decode()) - raise MissingHeadingError(e) from None + raise MissingHeadingError from e if title != section_title: title = f"{title} - {section_title}" diff --git a/tests/test_extract.py b/tests/test_extract.py index 77f4f24..ee6a047 100644 --- a/tests/test_extract.py +++ b/tests/test_extract.py @@ -30,7 +30,7 @@ def test_extract_sphinx_error(caplog): parse("failure", "index.html"), ) - assert str(excinfo.value) == "list index out of range" + assert str(excinfo.value) == "" assert len(caplog.records) == 1 assert caplog.records[0].levelname == "ERROR" assert caplog.records[0].message == 'No heading found\n
\n No heading.\n
\n'