Sha256: 560f80c598131203eacaaae9bc8e398bfbd92331f6a3fb605ebb4cbc9204ae56

Contents?: true

Size: 1.51 KB

Versions: 5

Compression:

Stored size: 1.51 KB

Contents

# -*- coding: utf-8 -*-
"""
    Pygments LaTeX formatter tests
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

from __future__ import print_function

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

5 entries across 5 versions & 2 rubygems

Version Path
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/pygments.rb-0.6.3/vendor/pygments-main/tests/test_latex_formatter.py
pygments.rb-0.6.3 vendor/pygments-main/tests/test_latex_formatter.py
pygments.rb-0.6.2 vendor/pygments-main/tests/test_latex_formatter.py
pygments.rb-0.6.1 vendor/pygments-main/tests/test_latex_formatter.py
pygments.rb-0.6.0 vendor/pygments-main/tests/test_latex_formatter.py