From ecc478cd3125e728a5047cb23a203d89d1605b2c Mon Sep 17 00:00:00 2001 From: Vladimir Hasko Date: Wed, 19 Apr 2023 06:27:15 +0000 Subject: [PATCH] fixing th condition and adding one more unit test --- otc_doc_convertor/convertor.py | 2 +- otc_doc_convertor/tests/unit/test_convertor.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/otc_doc_convertor/convertor.py b/otc_doc_convertor/convertor.py index 3709962f7..305c0c41b 100644 --- a/otc_doc_convertor/convertor.py +++ b/otc_doc_convertor/convertor.py @@ -224,7 +224,7 @@ class OTCDocConvertor: # Drop strong in table headers "/" for th in soup.body.find_all("th"): - if th and th.p.strong: + if th.p and th.p.strong: th.p.strong.unwrap() if args and args.improve_table_headers: diff --git a/otc_doc_convertor/tests/unit/test_convertor.py b/otc_doc_convertor/tests/unit/test_convertor.py index a1a2a865b..82b402873 100644 --- a/otc_doc_convertor/tests/unit/test_convertor.py +++ b/otc_doc_convertor/tests/unit/test_convertor.py @@ -233,3 +233,17 @@ class TestConvertor(TestCase): str(res.find('th')), expected.strip(), ) + + def test_streamline_html_escape_17(self): + test_data= """ + Mandatory + """ # noqa + expected = """ + Mandatory + """ # noqa + soup = bs4.BeautifulSoup(test_data, 'lxml') + res = self.convertor.streamline_html(soup, "dummy") + self.assertEqual( + str(res.find('th')), + expected.strip(), + )