def test_fontifyPythonNode(self): """ L{tree.fontifyPythonNode} accepts a text node and replaces it in its parent with a syntax colored and line numbered version of the Python source it contains. """ parent = dom.Element('div') source = dom.Text() source.data = 'def foo():\n pass\n' parent.appendChild(source) tree.fontifyPythonNode(source) expected = """\ <div><pre class="python"><p class="py-linenumber">1 2 </p><span class="py-src-keyword">def</span> <span class="py-src-identifier">foo</span>(): <span class="py-src-keyword">pass</span> </pre></div>""" self.assertEqual(parent.toxml(), expected)