def test_no_a_tags(self): """Make sure that content is returned properly if no a tag in content""" html = ''' <p> <h1>Test</h1> </p> ''' soup = BeautifulSoup(html) fixed_html = strip_a_tags(soup.prettify()) expected_html = '<p>\n <h1>\n Test\n </h1>\n</p>\n' self.assertEqual(fixed_html, expected_html)
def test_strip_a_tags(self): """Make sure that the a tags have no space inside""" html = ''' <p> <h1>Test</h1> <a class="link" href="/"> Cool </a> <div> <a href="/test"> Test </a> </div> </p> ''' soup = BeautifulSoup(html) fixed_html = strip_a_tags(soup.prettify()) expected_html = '<p>\n <h1>\n Test\n </h1>\n <a class="link" href="/">Cool</a>\n <div>\n ' \ '<a href="/test">Test</a>\n </div>\n</p>\n' self.assertEqual(fixed_html, expected_html)