'Assert that a given doctype string is handled correctly.'

def assertDoctypeHandled(self, doctype_fragment):

    (doctype_str, soup) = self._document_with_doctype(doctype_fragment)
    doctype = soup.contents[0]
    self.assertEqual(doctype.__class__, Doctype)
    self.assertEqual(doctype, doctype_fragment)
    self.assertEqual(str(soup)[:len(doctype_str)], doctype_str)
    self.assertEqual(soup.p.contents[0], 'foo')
