1
# Copyright (c) 2009 Twisted Matrix Laboratories.
2
# See LICENSE for details.
5
Tests for L{twisted.lore.lmath}.
8
from xml.dom.minidom import Element, Text
10
from twisted.trial.unittest import TestCase
11
from twisted.python.filepath import FilePath
13
from twisted.lore.lmath import formulaeToImages
16
class FormulaeTests(TestCase):
18
Tests for L{formulaeToImages}.
20
def test_insertImages(self):
22
L{formulaeToImages} replaces any elements with the I{latexformula}
23
class with I{img} elements which refer to external images generated
24
based on the latex in the original elements.
26
parent = Element('div')
27
base = FilePath(self.mktemp())
30
macros = Element('span')
31
macros.setAttribute('class', 'latexmacros')
34
macros.appendChild(text)
35
parent.appendChild(macros)
37
formula = Element('span')
38
formula.setAttribute('class', 'latexformula')
41
formula.appendChild(text)
42
parent.appendChild(formula)
44
# Avoid actually executing the commands to generate images from the
45
# latex. It might be nice to have some assertions about what commands
46
# are executed, or perhaps even execute them and make sure an image
47
# file is created, but that is a task for another day.
49
formulaeToImages(parent, base.path, _system=commands.append)
53
'<div><span><br/><img src="latexformula0.png"/><br/></span></div>')