From 59d1b237cd55710001c79e73c19292e340587ebe Mon Sep 17 00:00:00 2001 From: micha91 Date: Thu, 1 Aug 2024 17:27:53 +0200 Subject: [PATCH] chore: Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ernst Würger --- .../converters/polarion_html_helper.py | 3 +-- tests/test_documents.py | 22 +++++-------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/capella2polarion/converters/polarion_html_helper.py b/capella2polarion/converters/polarion_html_helper.py index 57caf8d3..4a7d4cf5 100644 --- a/capella2polarion/converters/polarion_html_helper.py +++ b/capella2polarion/converters/polarion_html_helper.py @@ -141,8 +141,7 @@ def extract_headings(html_content: str | list[etree._Element]) -> list[str]: for element in html_fragments: if h_regex.fullmatch(element.tag): - matches = wi_regex.match(element.get("id")) - if matches: + if matches := wi_regex.match(element.get("id")): heading_ids.append(matches.group(1)) return heading_ids diff --git a/tests/test_documents.py b/tests/test_documents.py index 10e4c48b..03b33a61 100644 --- a/tests/test_documents.py +++ b/tests/test_documents.py @@ -187,29 +187,18 @@ def test_mixed_authority_document( ) assert len(content) == 15 - assert content[0].tag == "h1" - assert content[1].tag == "p" - assert content[2].tag == "p" - assert ( - etree.tostring(content[4]) - .decode("utf-8") - .startswith("

New Heading

") - ) + assert [c.tag for c in content[:3]] == ["h1", "p", "p"] + assert (c4 := content[4]).tag == "h3" and c4.text == "New Heading" assert content[5].text == "Global Test" assert content[6].text == "Local Test section 1" assert content[8].text == "This will be kept." - assert ( - etree.tostring(content[10]) - .decode("utf-8") - .startswith( - '