A fake sax parser that calls some of the harder-to-reach sax methods to ensure it emits the correct events
| 233 | |
| 234 | |
| 235 | class SAXExerciser(object): |
| 236 | """A fake sax parser that calls some of the harder-to-reach sax methods to |
| 237 | ensure it emits the correct events""" |
| 238 | |
| 239 | def setContentHandler(self, handler): |
| 240 | self._handler = handler |
| 241 | |
| 242 | def parse(self, _): |
| 243 | h = self._handler |
| 244 | h.startDocument() |
| 245 | |
| 246 | # The next two items ensure that items preceding the first |
| 247 | # start_element are properly stored and emitted: |
| 248 | h.comment("a comment") |
| 249 | h.processingInstruction("target", "data") |
| 250 | |
| 251 | h.startElement("html", AttributesImpl({})) |
| 252 | |
| 253 | h.comment("a comment") |
| 254 | h.processingInstruction("target", "data") |
| 255 | |
| 256 | h.startElement("p", AttributesImpl({"class": "paraclass"})) |
| 257 | h.characters("text") |
| 258 | h.endElement("p") |
| 259 | h.endElement("html") |
| 260 | h.endDocument() |
| 261 | |
| 262 | def stub(self, *args, **kwargs): |
| 263 | """Stub method. Does nothing.""" |
| 264 | pass |
| 265 | setProperty = stub |
| 266 | setFeature = stub |
| 267 | |
| 268 | |
| 269 | class SAX2DOMExerciser(SAXExerciser): |
no outgoing calls
searching dependent graphs…