import unittest from bs4 import BeautifulSoup from bs4.formatter import HTMLFormatter from html_to_django.formatters.remove_default_formatter import format class TestFormatFunction(unittest.TestCase): # The strings here look weird because of the indentation and line breaks, but it must be this way def test_basic(self) -> None: html = """ Title

Test

""" soup = BeautifulSoup(html, "html.parser") format(soup) expected_result = "

\n Test\n

\n" self.assertEqual(expected_result, soup.prettify(formatter=HTMLFormatter(indent=4)))