--- a/tests/run.py +++ b/tests/run.py @@ -17,6 +17,7 @@ from __future__ import print_function import os import sys import warnings +import unittest # only find tests in this directory if os.path.dirname(__file__): @@ -30,12 +31,6 @@ warnings.filterwarnings("error", module= category=DeprecationWarning) -try: - import nose -except ImportError: - print('nose is required to run the Pygments test suite') - sys.exit(1) - # make sure the current source is first on sys.path sys.path.insert(0, '..') @@ -55,4 +50,4 @@ else: print('Pygments test suite running (Python %s)...' % sys.version.split()[0], file=sys.stderr) -nose.main() +unittest.main() --- a/tests/support.py +++ b/tests/support.py @@ -5,7 +5,7 @@ Support for Pygments tests import os -from nose import SkipTest +from unittest import SkipTest def location(mod_name): --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -16,11 +16,10 @@ import sys import tempfile import unittest -import support +from . import support from pygments import cmdline, highlight from pygments.util import BytesIO, StringIO - TESTFILE, TESTDIR = support.location(__file__) TESTCODE = '''\ def func(args): @@ -46,7 +45,7 @@ def run_cmdline(*args, **kwds): new_stdin.write(kwds.get('stdin', '')) new_stdin.seek(0, 0) try: - ret = cmdline.main(['pygmentize'] + list(args)) + ret = cmdline.main(['./pygmentize'] + list(args)) finally: sys.stdin = saved_stdin sys.stdout = saved_stdout @@ -111,8 +110,8 @@ class CmdLineTest(unittest.TestCase): os.unlink(name) def test_load_from_file(self): - lexer_file = os.path.join(TESTDIR, 'support', 'python_lexer.py') - formatter_file = os.path.join(TESTDIR, 'support', 'html_formatter.py') + lexer_file = os.path.join('tests', 'support', 'python_lexer.py') + formatter_file = os.path.join('tests', 'support', 'html_formatter.py') # By default, use CustomLexer o = self.check_success('-l', lexer_file, '-f', 'html', @@ -143,7 +142,7 @@ class CmdLineTest(unittest.TestCase): def test_h_opt(self): o = self.check_success('-h') - self.assertTrue('Usage:' in o) + self.assertIn('Usage:', o) def test_L_opt(self): o = self.check_success('-L') @@ -157,37 +156,37 @@ class CmdLineTest(unittest.TestCase): filename = TESTFILE o = self.check_success('-Ofull=1,linenos=true,foo=bar', '-fhtml', filename) - self.assertTrue('foo, bar=baz=,' in o) + self.assertIn('foo, bar=baz=,', o) def test_F_opt(self): filename = TESTFILE o = self.check_success('-Fhighlight:tokentype=Name.Blubb,' 'names=TESTFILE filename', '-fhtml', filename) - self.assertTrue('