FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-47042: Fix testing the HTML output in test_pydoc by serhiy-storchaka · Pull Request #31959 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 10 additions & 6 deletions Lib/test/test_pydoc.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,10 @@ def html2text(html):

Tailored for pydoc tests only.
"""
return pydoc.replace(
re.sub("<.*?>", "", html),
"&nbsp;", " ", "&gt;", ">", "&lt;", "<")
html = html.replace("<dd>", "\n")
html = re.sub("<.*?>", "", html)
html = pydoc.replace(html, "&nbsp;", " ", "&gt;", ">", "&lt;", "<")
return html


class PydocBaseTest(unittest.TestCase):
Expand Down Expand Up @@ -384,9 +385,12 @@ class PydocDocTest(unittest.TestCase):
def test_html_doc(self):
result, doc_loc = get_pydoc_html(pydoc_mod)
text_result = html2text(result)
expected_lines = [line.strip() for line in html2text_of_expected if line]
for line in expected_lines:
self.assertIn(line, text_result)
text_lines = [line.strip() for line in text_result.splitlines()]
text_lines = [line for line in text_lines if line]
del text_lines[1]
expected_lines = html2text_of_expected.splitlines()
expected_lines = [line.strip() for line in expected_lines if line]
self.assertEqual(text_lines, expected_lines)
mod_file = inspect.getabsfile(pydoc_mod)
mod_url = urllib.parse.quote(mod_file)
self.assertIn(mod_url, result)
Expand Down

Back | FazBrowse Home | New Git URL