From 4d27daa332b301a8cfcf0cac6345d56bfc17e5fe Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 6 May 2019 18:02:47 +0200 Subject: Remove unittest classes from the test suite. --- tests/test_latex_formatter.py | 63 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 33 deletions(-) (limited to 'tests/test_latex_formatter.py') diff --git a/tests/test_latex_formatter.py b/tests/test_latex_formatter.py index 9e0dd77c..7ab0d7d0 100644 --- a/tests/test_latex_formatter.py +++ b/tests/test_latex_formatter.py @@ -3,14 +3,13 @@ Pygments LaTeX formatter tests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ from __future__ import print_function import os -import unittest import tempfile from os import path @@ -23,34 +22,32 @@ TESTDIR = path.dirname(path.abspath(__file__)) TESTFILE = path.join(TESTDIR, 'test_latex_formatter.py') -class LatexFormatterTest(unittest.TestCase): - - def test_valid_output(self): - with open(TESTFILE) as fp: - tokensource = list(PythonLexer().get_tokens(fp.read())) - 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 as e: - # latex not available - pytest.skip(str(e)) - else: - if ret: - print(output) - self.assertFalse(ret, 'latex run reported errors') - - os.unlink(pathname) - os.chdir(old_wd) +def test_valid_output(): + with open(TESTFILE) as fp: + tokensource = list(PythonLexer().get_tokens(fp.read())) + 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 as e: + # latex not available + pytest.skip(str(e)) + else: + if ret: + print(output) + assert not ret, 'latex run reported errors' + + os.unlink(pathname) + os.chdir(old_wd) -- cgit v1.2.1