1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
"""
unit tests of the latex writer
"""
import unittest
import subprocess
import tempfile
import os
import sys
import BeautifulSoup
from pyth.plugins.latex.writer import LatexWriter
from pyth.plugins.python.reader import *
class TestWriteLatex(unittest.TestCase):
def test_basic(self):
"""
Try to create an empty latex document
"""
doc = PythonReader.read([])
latex = LatexWriter.write(doc).getvalue()
def test_paragraph(self):
"""
Try a single paragraph document
"""
doc = PythonReader.read(P[u"the text"])
latex = LatexWriter.write(doc).getvalue()
assert "the text" in latex
def test_bold(self):
doc = PythonReader.read([P[T(BOLD)[u"bold text"]]])
latex = LatexWriter.write(doc).getvalue()
assert r"\textbf{bold text}" in latex, latex
def test_italic(self):
doc = PythonReader.read([P[T(ITALIC)[u"italic text"]]])
latex = LatexWriter.write(doc).getvalue()
assert r"\emph{italic text}" in latex, latex
def test_metadata(self):
"""
assert that the document metadata are added into the latex file
"""
doc = PythonReader.read([])
doc["author"] = "The Author"
doc["subject"] = "The Subject"
doc["title"] = "The Title"
latex = LatexWriter.write(doc).getvalue()
assert "pdfauthor={The Author}" in latex, latex
assert "pdfsubject={The Subject}" in latex, latex
assert "pdftitle={The Title}" in latex, latex
|