Sha256: e9d71826dc3b760e5d1d05c47b4e645cd3c62002eec8b1d1c52d9937620ff40f
Contents?: true
Size: 1.47 KB
Versions: 13
Compression:
Stored size: 1.47 KB
Contents
# -*- coding: utf-8 -*- """ Pygments LaTeX formatter tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ import os import unittest import tempfile from pygments.formatters import LatexFormatter from pygments.lexers import PythonLexer import support TESTFILE, TESTDIR = support.location(__file__) class LatexFormatterTest(unittest.TestCase): def test_valid_output(self): fp = open(TESTFILE) try: tokensource = list(PythonLexer().get_tokens(fp.read())) finally: fp.close() fmt = LatexFormatter(full=True, encoding='latin1') handle, pathname = tempfile.mkstemp('.tex') # place all output files in /tmp too old_wd = os.getcwd() os.chdir(os.path.dirname(pathname)) tfile = os.fdopen(handle, 'wb') fmt.format(tokensource, tfile) tfile.close() try: import subprocess po = subprocess.Popen(['latex', '-interaction=nonstopmode', pathname], stdout=subprocess.PIPE) ret = po.wait() output = po.stdout.read() po.stdout.close() except OSError: # latex not available pass else: if ret: print output self.assertFalse(ret, 'latex run reported errors') os.unlink(pathname) os.chdir(old_wd)
Version data entries
13 entries across 13 versions & 4 rubygems