Beispiel #1
0
 def assert_html_equal(self, html, expected):
     try:
         from BeautifulSoup import BeautifulSoup
         html, expected = BeautifulSoup(html).prettify(), \
             BeautifulSoup(expected).prettify()
     except ImportError:
         html += '\n'
         expected += '\n'
     if html != expected:
         raise Exception(
             ' html is not as expected. Diff is following '
             '(1st diff line: html, 2nd diff line: expected)\n%s' % ''.join(
                 difflib.ndiff(html.splitlines(1), expected.splitlines(2))))
Beispiel #2
0
 def assert_html_equal(self, html, expected):
     try:
         from BeautifulSoup import BeautifulSoup
         html, expected = BeautifulSoup(html).prettify(), \
             BeautifulSoup(expected).prettify()
     except ImportError:
         html += '\n'
         expected += '\n'
     if html != expected:
         raise Exception(' html is not as expected. Diff is following '
                         '(1st diff line: html, 2nd diff line: expected)\n%s'
                         % ''.join(difflib.ndiff(html.splitlines(1),
                                                 expected.splitlines(2))))
Beispiel #3
0
    def parseBridgesFromHTMLPage(self, page):
        """Utility to pull the bridge lines out of an HTML response page.

        :param str page: A rendered HTML page, as a string.
        :raises: Any error which might occur.
        :rtype: list
        :returns: A list of the bridge lines contained on the **page**.
        """
        # The bridge lines are contained in a <pre> tag:
        soup = BeautifulSoup(page).find('pre')
        soup = str(soup).replace('<pre>', '').strip()
        soup = str(soup).replace('</pre>', '').strip()
        bridges = [b.strip() for b in soup.splitlines()]
        return bridges