MCPcopy Index your code
hub / github.com/python/cpython / test_handlers

Method test_handlers

Lib/test/test_sax.py:1467–1498  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1465 self.comments = []
1466
1467 def test_handlers(self):
1468 class TestLexicalHandler(LexicalHandler):
1469 def __init__(self, test_harness, *args, **kwargs):
1470 super().__init__(*args, **kwargs)
1471 self.test_harness = test_harness
1472
1473 def startDTD(self, doctype, publicID, systemID):
1474 self.test_harness.doctype = doctype
1475 self.test_harness.publicID = publicID
1476 self.test_harness.systemID = systemID
1477
1478 def endDTD(self):
1479 self.test_harness.end_of_dtd = True
1480
1481 def comment(self, text):
1482 self.test_harness.comments.append(text)
1483
1484 self.parser = create_parser()
1485 self.parser.setContentHandler(ContentHandler())
1486 self.parser.setProperty(
1487 'http://xml.org/sax/properties/lexical-handler',
1488 TestLexicalHandler(self))
1489 source = InputSource()
1490 source.setCharacterStream(self.test_data)
1491 self.parser.parse(source)
1492 self.assertEqual(self.doctype, self.specified_doctype)
1493 self.assertIsNone(self.publicID)
1494 self.assertIsNone(self.systemID)
1495 self.assertTrue(self.end_of_dtd)
1496 self.assertEqual(len(self.comments),
1497 len(self.specified_comment))
1498 self.assertEqual(f' {self.specified_comment[0]} ', self.comments[0])
1499
1500
1501class CDATAHandlerTest(unittest.TestCase):

Callers

nothing calls this directly

Calls 11

setCharacterStreamMethod · 0.95
create_parserFunction · 0.90
ContentHandlerClass · 0.90
InputSourceClass · 0.90
assertIsNoneMethod · 0.80
assertTrueMethod · 0.80
TestLexicalHandlerClass · 0.70
setContentHandlerMethod · 0.45
setPropertyMethod · 0.45
parseMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected