summaryrefslogtreecommitdiff
path: root/tests/test_basic_api.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2021-01-17 07:44:58 -0800
committerGitHub <noreply@github.com>2021-01-17 16:44:58 +0100
commitdebda34e2d4f28d6d369cdafdcba4791702f63fc (patch)
tree68799677bf5f81be5e32af24670277721adc5845 /tests/test_basic_api.py
parent19d2096185de3282345eab1da611e56a26bcaec2 (diff)
downloadpygments-git-debda34e2d4f28d6d369cdafdcba4791702f63fc.tar.gz
Run pyupgrade across codebase to modernize syntax and patterns (#1622)
pyupgrade is a tool to automatically upgrade syntax for newer versions of the Python language. The project has been Python 3 only since 35544e2fc6eed0ce4a27ec7285aac71ff0ddc473, allowing for several cleanups: - Remove unnecessary "-*- coding: utf-8 -*-" cookie. Python 3 reads all source files as utf-8 by default. - Replace IOError/EnvironmentError with OSError. Python 3 unified these exceptions. The old names are aliases only. - Use the Python 3 shorter super() syntax. - Remove "utf8" argument form encode/decode. In Python 3, this value is the default. - Remove "r" from open() calls. In Python 3, this value is the default. - Remove u prefix from Unicode strings. In Python 3, all strings are Unicode. - Replace io.open() with builtin open(). In Python 3, these functions are functionally equivalent. Co-authored-by: Matthäus G. Chajdas <Anteru@users.noreply.github.com>
Diffstat (limited to 'tests/test_basic_api.py')
-rw-r--r--tests/test_basic_api.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py
index b860060b..24e42ca2 100644
--- a/tests/test_basic_api.py
+++ b/tests/test_basic_api.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
Pygments basic API tests
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -186,7 +185,7 @@ def test_formatter_encodings():
# encoding and outencoding option
fmt = HtmlFormatter(encoding="latin1", outencoding="utf8")
tokens = [(Text, "ä")]
- assert "ä".encode("utf8") in format(tokens, fmt)
+ assert "ä".encode() in format(tokens, fmt)
@pytest.mark.parametrize('cls', [getattr(formatters, name)
@@ -272,7 +271,7 @@ class TestFilters:
# We don't read as binary and decode, but instead read as text, as
# we need consistent line endings. Otherwise we'll get \r\n on
# Windows
- with open(TESTFILE, 'r', encoding='utf-8') as fp:
+ with open(TESTFILE, encoding='utf-8') as fp:
text = fp.read()
tokens = list(lx.get_tokens(text))
assert all(isinstance(t[1], str) for t in tokens), \