summaryrefslogtreecommitdiff
path: root/tests/test_basic_api.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2020-02-29 15:45:08 +0100
committerGitHub <noreply@github.com>2020-02-29 15:45:08 +0100
commit35544e2fc6eed0ce4a27ec7285aac71ff0ddc473 (patch)
tree4390507bf0d4d5a4596cfc57c575da12f9da40f9 /tests/test_basic_api.py
parent14fc057d300102d88a07eda5558f238d49dd23f6 (diff)
downloadpygments-git-35544e2fc6eed0ce4a27ec7285aac71ff0ddc473.tar.gz
Remove Python 2 compatibility (#1348)
* Remove Python 2 compatibility * remove 2/3 shims in pygments.util * update setup.py metadata * Remove unneeded object inheritance. * Remove unneeded future imports.
Diffstat (limited to 'tests/test_basic_api.py')
-rw-r--r--tests/test_basic_api.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py
index 7d08c05e..7f71791e 100644
--- a/tests/test_basic_api.py
+++ b/tests/test_basic_api.py
@@ -7,9 +7,8 @@
:license: BSD, see LICENSE for details.
"""
-from __future__ import print_function
-
import random
+from io import StringIO, BytesIO
from os import path
import pytest
@@ -18,12 +17,12 @@ from pygments import lexers, formatters, lex, format
from pygments.token import _TokenType, Text
from pygments.lexer import RegexLexer
from pygments.formatters.img import FontNotFound
-from pygments.util import text_type, StringIO, BytesIO, xrange, ClassNotFound
+from pygments.util import ClassNotFound
TESTDIR = path.dirname(path.abspath(__file__))
TESTFILE = path.join(TESTDIR, 'test_basic_api.py')
-test_content = [chr(i) for i in xrange(33, 128)] * 5
+test_content = [chr(i) for i in range(33, 128)] * 5
random.shuffle(test_content)
test_content = ''.join(test_content) + '\n'
@@ -75,7 +74,7 @@ def test_random_input(cls):
for token in tokens:
assert isinstance(token, tuple)
assert isinstance(token[0], _TokenType)
- assert isinstance(token[1], text_type)
+ assert isinstance(token[1], str)
txt += token[1]
assert txt == test_content, "%s lexer roundtrip failed: %r != %r" % \
(cls.name, test_content, txt)
@@ -176,7 +175,7 @@ def test_formatter_encodings():
fmt = HtmlFormatter()
tokens = [(Text, u"ä")]
out = format(tokens, fmt)
- assert type(out) is text_type
+ assert type(out) is str
assert u"ä" in out
# encoding option
@@ -206,7 +205,7 @@ def test_formatter_unicode_handling(cls):
if cls.name != 'Raw tokens':
out = format(tokens, inst)
if cls.unicodeoutput:
- assert type(out) is text_type, '%s: %r' % (cls, out)
+ assert type(out) is str, '%s: %r' % (cls, out)
inst = cls(encoding='utf-8')
out = format(tokens, inst)
@@ -253,7 +252,7 @@ def test_bare_class_handler():
assert False, 'nothing raised'
-class TestFilters(object):
+class TestFilters:
def test_basic(self):
filters_args = [
@@ -272,7 +271,7 @@ class TestFilters(object):
with open(TESTFILE, 'rb') as fp:
text = fp.read().decode('utf-8')
tokens = list(lx.get_tokens(text))
- assert all(isinstance(t[1], text_type) for t in tokens), \
+ assert all(isinstance(t[1], str) for t in tokens), \
'%s filter did not return Unicode' % x
roundtext = ''.join([t[1] for t in tokens])
if x not in ('whitespace', 'keywordcase', 'gobble'):