Skip to content

Commit

Permalink
Add soup_to_md function to test_bs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipMay committed Jan 1, 2024
1 parent 0e7a5f7 commit e8bc853
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/test_bs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
from bs4 import BeautifulSoup

from mltb2.bs import extract_all, extract_one, extract_text
from mltb2.bs import extract_all, extract_one, extract_text, soup_to_md

# this code snippet is from the BeautifulSoup documentation
# MIT License
Expand All @@ -22,8 +22,7 @@
<a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>;
and they lived at the bottom of a well.</p>
<p class="story">...</p>
"""
<p class="story">...</p>"""


@pytest.fixture
Expand Down Expand Up @@ -52,3 +51,12 @@ def test_extract_all(my_soup: BeautifulSoup):
assert len(result) == 3
assert result[0].name == "a"
assert result[0].text == "Elsie"

def test_soup_to_md(my_soup: BeautifulSoup):
result = soup_to_md(my_soup)
assert result is not None
assert result == "The Dormouse's story **The Dormouse's story**\n\n"\
"Once upon a time there were three little sisters; "\
"and their names were [Elsie](http://example.com/elsie), "\
"[Lacie](http://example.com/lacie) and [Tillie](http://example.com/tillie); "\
"and they lived at the bottom of a well.\n\n...\n"

0 comments on commit e8bc853

Please sign in to comment.