MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / testConvertReleasesDocument

Method testConvertReleasesDocument

tests/test_apis.py:61–83  ·  view source on GitHub ↗

The parsed tree and source lines are released by `reset()`.

(self)

Source from the content-addressed store, hash-verified

59 self.assertEqual(self.md.convert('foo'), '<p>foo</p>')
60
61 def testConvertReleasesDocument(self):
62 """ The parsed tree and source lines are released by `reset()`. """
63 from markdown.treeprocessors import InlineProcessor
64
65 md = markdown.Markdown(extensions=['extra', 'toc'])
66 doc = '# Title\n\nThis is a [link](https://example.com) with *emphasis*.\n'
67 first = md.convert(doc)
68 # `md.lines` and `md.parser.root` stay available after parsing, as
69 # third-party extensions may read them, and are released by `reset()`.
70 self.assertTrue(md.lines)
71 self.assertIsNotNone(md.parser.root)
72 md.reset()
73 self.assertEqual(md.lines, [])
74 self.assertIsNone(md.parser.root)
75 self.assertEqual(md.convert(doc), first)
76 md.reset()
77 self.assertEqual(md.lines, [])
78 self.assertIsNone(md.parser.root)
79 inline = next(
80 tp for tp in md.treeprocessors if isinstance(tp, InlineProcessor)
81 )
82 self.assertEqual(inline.parent_map, {})
83 self.assertEqual(inline.stashed_nodes, {})
84
85 def testInstanceExtension(self):
86 """ Test Extension loading with a class instance. """

Callers

nothing calls this directly

Calls 2

convertMethod · 0.95
resetMethod · 0.95

Tested by

no test coverage detected