summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAdam Turner <9087854+aa-turner@users.noreply.github.com>2022-10-17 15:54:59 +0100
committerAdam Turner <9087854+aa-turner@users.noreply.github.com>2022-10-17 22:39:09 +0100
commit920828fe351b9e542206749e2ddf04a2cd17a6f3 (patch)
treeb3243d53e128a1fa5b40247b98b0c987ea5adbaf /tests
parentb277abcb49d2c6d248518ea30a179cb52175d600 (diff)
downloadsphinx-git-920828fe351b9e542206749e2ddf04a2cd17a6f3.tar.gz
Run the ``pyupgrade`` tool
Diffstat (limited to 'tests')
-rwxr-xr-xtests/roots/test-apidoc-toc/mypackage/main.py4
-rw-r--r--tests/roots/test-autosummary/underscore_module_.py2
-rw-r--r--tests/roots/test-changes/conf.py2
-rw-r--r--tests/roots/test-correct-year/conf.py1
-rw-r--r--tests/roots/test-directive-only/conf.py1
-rw-r--r--tests/roots/test-ext-autodoc/autodoc_dummy_bar.py2
-rw-r--r--tests/roots/test-ext-autodoc/bug2437/autodoc_dummy_foo.py2
-rw-r--r--tests/roots/test-ext-autodoc/target/__init__.py14
-rw-r--r--tests/roots/test-ext-autodoc/target/descriptor.py2
-rw-r--r--tests/roots/test-ext-autodoc/target/inheritance.py2
-rw-r--r--tests/roots/test-ext-autodoc/target/need_mocks.py3
-rw-r--r--tests/roots/test-ext-autodoc/target/partialmethod.py2
-rw-r--r--tests/roots/test-ext-autodoc/target/typed_vars.py2
-rw-r--r--tests/roots/test-ext-inheritance_diagram/example/sphinx.py2
-rw-r--r--tests/roots/test-ext-inheritance_diagram/test.py2
-rw-r--r--tests/roots/test-ext-viewcode-find/not_a_package/submodule.py4
-rw-r--r--tests/roots/test-inheritance/dummy/test.py2
-rw-r--r--tests/roots/test-inheritance/dummy/test_nested.py4
-rw-r--r--tests/roots/test-root/autodoc_target.py14
-rw-r--r--tests/roots/test-warnings/autodoc_fodder.py3
-rw-r--r--tests/test_build_epub.py6
-rw-r--r--tests/test_build_gettext.py6
-rw-r--r--tests/test_build_html.py6
-rw-r--r--tests/test_build_latex.py6
-rw-r--r--tests/test_build_texinfo.py4
-rw-r--r--tests/test_domain_c.py18
-rw-r--r--tests/test_domain_cpp.py16
-rw-r--r--tests/test_ext_apidoc.py4
-rw-r--r--tests/test_ext_doctest.py2
-rw-r--r--tests/test_ext_imgconverter.py3
-rw-r--r--tests/test_util_inspect.py2
31 files changed, 68 insertions, 75 deletions
diff --git a/tests/roots/test-apidoc-toc/mypackage/main.py b/tests/roots/test-apidoc-toc/mypackage/main.py
index d448cc847..f532813a7 100755
--- a/tests/roots/test-apidoc-toc/mypackage/main.py
+++ b/tests/roots/test-apidoc-toc/mypackage/main.py
@@ -6,10 +6,10 @@ import mod_resource
import mod_something
if __name__ == "__main__":
- print("Hello, world! -> something returns: {}".format(mod_something.something()))
+ print(f"Hello, world! -> something returns: {mod_something.something()}")
res_path = \
os.path.join(os.path.dirname(mod_resource.__file__), 'resource.txt')
with open(res_path, encoding='utf-8') as f:
text = f.read()
- print("From mod_resource:resource.txt -> {}".format(text))
+ print(f"From mod_resource:resource.txt -> {text}")
diff --git a/tests/roots/test-autosummary/underscore_module_.py b/tests/roots/test-autosummary/underscore_module_.py
index c18697cd2..8584e6078 100644
--- a/tests/roots/test-autosummary/underscore_module_.py
+++ b/tests/roots/test-autosummary/underscore_module_.py
@@ -3,7 +3,7 @@ module with trailing underscores everywhere
"""
-class class_(object):
+class class_:
""" Class """
def method_(_arg):
""" Method """
diff --git a/tests/roots/test-changes/conf.py b/tests/roots/test-changes/conf.py
index 2fedcb199..e9158c429 100644
--- a/tests/roots/test-changes/conf.py
+++ b/tests/roots/test-changes/conf.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
project = 'Sphinx ChangesBuilder tests'
copyright = '2007-2022 by the Sphinx team, see AUTHORS'
version = '0.6'
diff --git a/tests/roots/test-correct-year/conf.py b/tests/roots/test-correct-year/conf.py
index 6aac1743e..814c08b55 100644
--- a/tests/roots/test-correct-year/conf.py
+++ b/tests/roots/test-correct-year/conf.py
@@ -1,2 +1 @@
-
copyright = '2006-2009, Author'
diff --git a/tests/roots/test-directive-only/conf.py b/tests/roots/test-directive-only/conf.py
index b9209f08b..191d0f598 100644
--- a/tests/roots/test-directive-only/conf.py
+++ b/tests/roots/test-directive-only/conf.py
@@ -1,3 +1,2 @@
-
project = 'test-directive-only'
exclude_patterns = ['_build']
diff --git a/tests/roots/test-ext-autodoc/autodoc_dummy_bar.py b/tests/roots/test-ext-autodoc/autodoc_dummy_bar.py
index 151818b36..3b5bbfdd1 100644
--- a/tests/roots/test-ext-autodoc/autodoc_dummy_bar.py
+++ b/tests/roots/test-ext-autodoc/autodoc_dummy_bar.py
@@ -1,6 +1,6 @@
from bug2437.autodoc_dummy_foo import Foo
-class Bar(object):
+class Bar:
"""Dummy class Bar with alias."""
my_name = Foo
diff --git a/tests/roots/test-ext-autodoc/bug2437/autodoc_dummy_foo.py b/tests/roots/test-ext-autodoc/bug2437/autodoc_dummy_foo.py
index b578a2255..9c954d80a 100644
--- a/tests/roots/test-ext-autodoc/bug2437/autodoc_dummy_foo.py
+++ b/tests/roots/test-ext-autodoc/bug2437/autodoc_dummy_foo.py
@@ -1,3 +1,3 @@
-class Foo(object):
+class Foo:
"""Dummy class Foo."""
pass
diff --git a/tests/roots/test-ext-autodoc/target/__init__.py b/tests/roots/test-ext-autodoc/target/__init__.py
index 0d39c6672..bb2290be6 100644
--- a/tests/roots/test-ext-autodoc/target/__init__.py
+++ b/tests/roots/test-ext-autodoc/target/__init__.py
@@ -33,7 +33,7 @@ def _funky_classmethod(name, b, c, d, docstring=None):
return classmethod(function)
-class Class(object):
+class Class:
"""Class to document."""
def meth(self):
@@ -96,10 +96,10 @@ def function(foo, *args, **kwds):
pass
-class Outer(object):
+class Outer:
"""Foo"""
- class Inner(object):
+ class Inner:
"""Foo"""
def meth(self):
@@ -113,7 +113,7 @@ class InnerChild(Outer.Inner):
"""InnerChild docstring"""
-class DocstringSig(object):
+class DocstringSig:
def __new__(cls, *new_args, **new_kwargs):
"""__new__(cls, d, e=1) -> DocstringSig
First line of docstring
@@ -164,12 +164,12 @@ class StrRepr(str):
return self
-class AttCls(object):
+class AttCls:
a1 = StrRepr('hello\nworld')
a2 = None
-class InstAttCls(object):
+class InstAttCls:
"""Class with documented class and instance attributes."""
#: Doc comment for class attribute InstAttCls.ca1.
@@ -189,7 +189,7 @@ class InstAttCls(object):
"""Docstring for instance attribute InstAttCls.ia2."""
-class CustomIter(object):
+class CustomIter:
def __init__(self):
"""Create a new `CustomIter`."""
self.values = range(10)
diff --git a/tests/roots/test-ext-autodoc/target/descriptor.py b/tests/roots/test-ext-autodoc/target/descriptor.py
index 63d179b65..2857c99f9 100644
--- a/tests/roots/test-ext-autodoc/target/descriptor.py
+++ b/tests/roots/test-ext-autodoc/target/descriptor.py
@@ -1,4 +1,4 @@
-class CustomDataDescriptor(object):
+class CustomDataDescriptor:
"""Descriptor class docstring."""
def __init__(self, doc):
diff --git a/tests/roots/test-ext-autodoc/target/inheritance.py b/tests/roots/test-ext-autodoc/target/inheritance.py
index 85d95cd74..e06f7a842 100644
--- a/tests/roots/test-ext-autodoc/target/inheritance.py
+++ b/tests/roots/test-ext-autodoc/target/inheritance.py
@@ -1,4 +1,4 @@
-class Base(object):
+class Base:
#: docstring
inheritedattr = None
diff --git a/tests/roots/test-ext-autodoc/target/need_mocks.py b/tests/roots/test-ext-autodoc/target/need_mocks.py
index 45b3ade06..881220bd0 100644
--- a/tests/roots/test-ext-autodoc/target/need_mocks.py
+++ b/tests/roots/test-ext-autodoc/target/need_mocks.py
@@ -1,4 +1,3 @@
-
import missing_module
import missing_package1.missing_module1
from missing_module import missing_name
@@ -20,7 +19,7 @@ def func(arg: missing_module.Class):
pass
-class TestAutodoc(object):
+class TestAutodoc:
"""TestAutodoc docstring."""
#: docstring
diff --git a/tests/roots/test-ext-autodoc/target/partialmethod.py b/tests/roots/test-ext-autodoc/target/partialmethod.py
index 82843461f..20d75e91d 100644
--- a/tests/roots/test-ext-autodoc/target/partialmethod.py
+++ b/tests/roots/test-ext-autodoc/target/partialmethod.py
@@ -1,7 +1,7 @@
from functools import partialmethod
-class Cell(object):
+class Cell:
"""An example for partialmethod.
refs: https://docs.python.jp/3/library/functools.html#functools.partialmethod
diff --git a/tests/roots/test-ext-autodoc/target/typed_vars.py b/tests/roots/test-ext-autodoc/target/typed_vars.py
index f909b80f1..0fe7468c8 100644
--- a/tests/roots/test-ext-autodoc/target/typed_vars.py
+++ b/tests/roots/test-ext-autodoc/target/typed_vars.py
@@ -8,7 +8,7 @@ attr3 = '' # type: str
class _Descriptor:
def __init__(self, name):
- self.__doc__ = "This is {}".format(name)
+ self.__doc__ = f"This is {name}"
def __get__(self):
pass
diff --git a/tests/roots/test-ext-inheritance_diagram/example/sphinx.py b/tests/roots/test-ext-inheritance_diagram/example/sphinx.py
index 5eb8a2291..2bfbf4c59 100644
--- a/tests/roots/test-ext-inheritance_diagram/example/sphinx.py
+++ b/tests/roots/test-ext-inheritance_diagram/example/sphinx.py
@@ -1,5 +1,5 @@
# example.sphinx
-class DummyClass(object):
+class DummyClass:
pass
diff --git a/tests/roots/test-ext-inheritance_diagram/test.py b/tests/roots/test-ext-inheritance_diagram/test.py
index 7d5cabeef..4f73c4707 100644
--- a/tests/roots/test-ext-inheritance_diagram/test.py
+++ b/tests/roots/test-ext-inheritance_diagram/test.py
@@ -1,4 +1,4 @@
-class Foo(object):
+class Foo:
pass
diff --git a/tests/roots/test-ext-viewcode-find/not_a_package/submodule.py b/tests/roots/test-ext-viewcode-find/not_a_package/submodule.py
index 7bb36943b..ba8be78de 100644
--- a/tests/roots/test-ext-viewcode-find/not_a_package/submodule.py
+++ b/tests/roots/test-ext-viewcode-find/not_a_package/submodule.py
@@ -17,13 +17,13 @@ def func1(a, b):
@decorator
-class Class1(object):
+class Class1:
"""
this is Class1
"""
-class Class3(object):
+class Class3:
"""
this is Class3
"""
diff --git a/tests/roots/test-inheritance/dummy/test.py b/tests/roots/test-inheritance/dummy/test.py
index 51bd9a7a4..12fe8d900 100644
--- a/tests/roots/test-inheritance/dummy/test.py
+++ b/tests/roots/test-inheritance/dummy/test.py
@@ -11,7 +11,7 @@ r"""
"""
-class A(object):
+class A:
pass
diff --git a/tests/roots/test-inheritance/dummy/test_nested.py b/tests/roots/test-inheritance/dummy/test_nested.py
index 89289fe44..4b6801892 100644
--- a/tests/roots/test-inheritance/dummy/test_nested.py
+++ b/tests/roots/test-inheritance/dummy/test_nested.py
@@ -2,8 +2,8 @@
"""
-class A(object):
- class B(object):
+class A:
+ class B:
pass
diff --git a/tests/roots/test-root/autodoc_target.py b/tests/roots/test-root/autodoc_target.py
index a49ffc1ff..59f6c74d6 100644
--- a/tests/roots/test-root/autodoc_target.py
+++ b/tests/roots/test-root/autodoc_target.py
@@ -19,7 +19,7 @@ class CustomEx(Exception):
"""Exception method."""
-class CustomDataDescriptor(object):
+class CustomDataDescriptor:
"""Descriptor class docstring."""
def __init__(self, doc):
@@ -56,7 +56,7 @@ def _funky_classmethod(name, b, c, d, docstring=None):
return classmethod(function)
-class Base(object):
+class Base:
def inheritedmeth(self):
"""Inherited function."""
@@ -136,10 +136,10 @@ def function(foo, *args, **kwds):
pass
-class Outer(object):
+class Outer:
"""Foo"""
- class Inner(object):
+ class Inner:
"""Foo"""
def meth(self):
@@ -149,7 +149,7 @@ class Outer(object):
factory = dict
-class DocstringSig(object):
+class DocstringSig:
def meth(self):
"""meth(FOO, BAR=1) -> BAZ
First line of docstring
@@ -184,12 +184,12 @@ class StrRepr(str):
return self
-class AttCls(object):
+class AttCls:
a1 = StrRepr('hello\nworld')
a2 = None
-class InstAttCls(object):
+class InstAttCls:
"""Class with documented class and instance attributes."""
#: Doc comment for class attribute InstAttCls.ca1.
diff --git a/tests/roots/test-warnings/autodoc_fodder.py b/tests/roots/test-warnings/autodoc_fodder.py
index e5fd74139..59e4e210f 100644
--- a/tests/roots/test-warnings/autodoc_fodder.py
+++ b/tests/roots/test-warnings/autodoc_fodder.py
@@ -1,5 +1,4 @@
-
-class MarkupError(object):
+class MarkupError:
"""
.. note:: This is a docstring with a
small markup error which should have
diff --git a/tests/test_build_epub.py b/tests/test_build_epub.py
index 80525112b..becde92cd 100644
--- a/tests/test_build_epub.py
+++ b/tests/test_build_epub.py
@@ -2,7 +2,7 @@
import os
import subprocess
-from subprocess import PIPE, CalledProcessError
+from subprocess import CalledProcessError
from xml.etree import ElementTree
import pytest
@@ -11,7 +11,7 @@ import pytest
# check given command is runnable
def runnable(command):
try:
- subprocess.run(command, stdout=PIPE, stderr=PIPE, check=True)
+ subprocess.run(command, capture_output=True, check=True)
return True
except (OSError, CalledProcessError):
return False # command not found or exit with non-zero
@@ -377,7 +377,7 @@ def test_run_epubcheck(app):
if runnable(['java', '-version']) and os.path.exists(epubcheck):
try:
subprocess.run(['java', '-jar', epubcheck, app.outdir / 'SphinxTests.epub'],
- stdout=PIPE, stderr=PIPE, check=True)
+ capture_output=True, check=True)
except CalledProcessError as exc:
print(exc.stdout.decode('utf-8'))
print(exc.stderr.decode('utf-8'))
diff --git a/tests/test_build_gettext.py b/tests/test_build_gettext.py
index 20fe60e85..630f0760c 100644
--- a/tests/test_build_gettext.py
+++ b/tests/test_build_gettext.py
@@ -4,7 +4,7 @@ import gettext
import os
import re
import subprocess
-from subprocess import PIPE, CalledProcessError
+from subprocess import CalledProcessError
import pytest
@@ -54,7 +54,7 @@ def test_msgfmt(app):
with cd(app.outdir):
try:
args = ['msginit', '--no-translator', '-i', 'markup.pot', '--locale', 'en_US']
- subprocess.run(args, stdout=PIPE, stderr=PIPE, check=True)
+ subprocess.run(args, capture_output=True, check=True)
except OSError:
pytest.skip() # most likely msginit was not found
except CalledProcessError as exc:
@@ -66,7 +66,7 @@ def test_msgfmt(app):
try:
args = ['msgfmt', 'en_US.po',
'-o', os.path.join('en', 'LC_MESSAGES', 'test_root.mo')]
- subprocess.run(args, stdout=PIPE, stderr=PIPE, check=True)
+ subprocess.run(args, capture_output=True, check=True)
except OSError:
pytest.skip() # most likely msgfmt was not found
except CalledProcessError as exc:
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index fa0bbac7c..dee65613f 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -105,9 +105,9 @@ def check_xpath(etree, fname, path, check, be_found=True):
if all(not rex.search(get_text(node)) for node in nodes):
return
- raise AssertionError(('%r not found in any node matching '
- 'path %s in %s: %r' % (check, path, fname,
- [node.text for node in nodes])))
+ raise AssertionError('%r not found in any node matching '
+ 'path %s in %s: %r' % (check, path, fname,
+ [node.text for node in nodes]))
@pytest.mark.sphinx('html', testroot='warnings')
diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py
index f8b06562b..bfb126953 100644
--- a/tests/test_build_latex.py
+++ b/tests/test_build_latex.py
@@ -5,7 +5,7 @@ import re
import subprocess
from itertools import product
from shutil import copyfile
-from subprocess import PIPE, CalledProcessError
+from subprocess import CalledProcessError
import pytest
@@ -36,7 +36,7 @@ LATEX_WARNINGS = ENV_WARNINGS + """\
# only run latex if all needed packages are there
def kpsetest(*filenames):
try:
- subprocess.run(['kpsewhich'] + list(filenames), stdout=PIPE, stderr=PIPE, check=True)
+ subprocess.run(['kpsewhich'] + list(filenames), capture_output=True, check=True)
return True
except (OSError, CalledProcessError):
return False # command not found or exit with non-zero
@@ -55,7 +55,7 @@ def compile_latex_document(app, filename='python.tex'):
'--interaction=nonstopmode',
'-output-directory=%s' % app.config.latex_engine,
filename]
- subprocess.run(args, stdout=PIPE, stderr=PIPE, check=True)
+ subprocess.run(args, capture_output=True, check=True)
except OSError as exc: # most likely the latex executable was not found
raise pytest.skip.Exception from exc
except CalledProcessError as exc:
diff --git a/tests/test_build_texinfo.py b/tests/test_build_texinfo.py
index b33a7e01f..974cb1965 100644
--- a/tests/test_build_texinfo.py
+++ b/tests/test_build_texinfo.py
@@ -3,7 +3,7 @@
import os
import re
import subprocess
-from subprocess import PIPE, CalledProcessError
+from subprocess import CalledProcessError
from unittest.mock import Mock
import pytest
@@ -49,7 +49,7 @@ def test_texinfo(app, status, warning):
# now, try to run makeinfo over it
try:
args = ['makeinfo', '--no-split', 'sphinxtests.texi']
- subprocess.run(args, stdout=PIPE, stderr=PIPE, cwd=app.outdir, check=True)
+ subprocess.run(args, capture_output=True, cwd=app.outdir, check=True)
except OSError as exc:
raise pytest.skip.Exception from exc # most likely makeinfo was not found
except CalledProcessError as exc:
diff --git a/tests/test_domain_c.py b/tests/test_domain_c.py
index 8a9a04568..9718297ab 100644
--- a/tests/test_domain_c.py
+++ b/tests/test_domain_c.py
@@ -470,12 +470,12 @@ def test_domain_c_ast_function_definitions():
cvrs = ['', 'const', 'volatile', 'restrict', 'restrict volatile const']
for cvr in cvrs:
space = ' ' if len(cvr) != 0 else ''
- check('function', 'void f(int arr[{}*])'.format(cvr), {1: 'f'})
- check('function', 'void f(int arr[{}])'.format(cvr), {1: 'f'})
- check('function', 'void f(int arr[{}{}42])'.format(cvr, space), {1: 'f'})
- check('function', 'void f(int arr[static{}{} 42])'.format(space, cvr), {1: 'f'})
- check('function', 'void f(int arr[{}{}static 42])'.format(cvr, space), {1: 'f'},
- output='void f(int arr[static{}{} 42])'.format(space, cvr))
+ check('function', f'void f(int arr[{cvr}*])', {1: 'f'})
+ check('function', f'void f(int arr[{cvr}])', {1: 'f'})
+ check('function', f'void f(int arr[{cvr}{space}42])', {1: 'f'})
+ check('function', f'void f(int arr[static{space}{cvr} 42])', {1: 'f'})
+ check('function', f'void f(int arr[{cvr}{space}static 42])', {1: 'f'},
+ output=f'void f(int arr[static{space}{cvr} 42])')
check('function', 'void f(int arr[const static volatile 42])', {1: 'f'},
output='void f(int arr[static volatile const 42])')
@@ -611,9 +611,9 @@ def split_warnigns(warning):
def filter_warnings(warning, file):
lines = split_warnigns(warning)
- res = [l for l in lines if "domain-c" in l and "{}.rst".format(file) in l and
+ res = [l for l in lines if "domain-c" in l and f"{file}.rst" in l and
"WARNING: document isn't included in any toctree" not in l]
- print("Filtered warnings for file '{}':".format(file))
+ print(f"Filtered warnings for file '{file}':")
for w in res:
print(w)
return res
@@ -652,7 +652,7 @@ def test_domain_c_build_namespace(app, status, warning):
assert len(ws) == 0
t = (app.outdir / "namespace.html").read_text(encoding='utf8')
for id_ in ('NS.NSVar', 'NULLVar', 'ZeroVar', 'NS2.NS3.NS2NS3Var', 'PopVar'):
- assert 'id="c.{}"'.format(id_) in t
+ assert f'id="c.{id_}"' in t
@pytest.mark.sphinx(testroot='domain-c', confoverrides={'nitpicky': True})
diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py
index 5e9bc6aa3..93a43c754 100644
--- a/tests/test_domain_cpp.py
+++ b/tests/test_domain_cpp.py
@@ -218,7 +218,7 @@ def test_domain_cpp_ast_expressions():
('\\U0001f34c', '127820'), ('\\U0001F34C', '127820')]
for p, t in charPrefixAndIds:
for c, val in chars:
- exprCheck("{}'{}'".format(p, c), t + val)
+ exprCheck(f"{p}'{c}'", t + val)
# user-defined literals
for i in ints:
exprCheck(i + '_udl', 'clL_Zli4_udlEL' + i.replace("'", "") + 'EE')
@@ -230,7 +230,7 @@ def test_domain_cpp_ast_expressions():
exprCheck('0x' + f + '_udl', 'clL_Zli4_udlEL0x' + f.replace("'", "") + 'EE')
for p, t in charPrefixAndIds:
for c, val in chars:
- exprCheck("{}'{}'_udl".format(p, c), 'clL_Zli4_udlE' + t + val + 'E')
+ exprCheck(f"{p}'{c}'_udl", 'clL_Zli4_udlE' + t + val + 'E')
exprCheck('"abc"_udl', 'clL_Zli4_udlELA3_KcEE')
# from issue #7294
exprCheck('6.62607015e-34q_J', 'clL_Zli3q_JEL6.62607015e-34EE')
@@ -1084,9 +1084,9 @@ def test_domain_cpp_template_parameters_is_pack(param: str, is_pack: bool):
def filter_warnings(warning, file):
lines = warning.getvalue().split("\n")
- res = [l for l in lines if "domain-cpp" in l and "{}.rst".format(file) in l and
+ res = [l for l in lines if "domain-cpp" in l and f"{file}.rst" in l and
"WARNING: document isn't included in any toctree" not in l]
- print("Filtered warnings for file '{}':".format(file))
+ print(f"Filtered warnings for file '{file}':")
for w in res:
print(w)
return res
@@ -1169,10 +1169,10 @@ def test_domain_cpp_build_misuse_of_roles(app, status, warning):
txtTargetType = "function" if targetType == "func" else targetType
for r in allRoles:
if r not in roles:
- warn.append("WARNING: cpp:{} targets a {} (".format(r, txtTargetType))
+ warn.append(f"WARNING: cpp:{r} targets a {txtTargetType} (")
if targetType == 'templateParam':
- warn.append("WARNING: cpp:{} targets a {} (".format(r, txtTargetType))
- warn.append("WARNING: cpp:{} targets a {} (".format(r, txtTargetType))
+ warn.append(f"WARNING: cpp:{r} targets a {txtTargetType} (")
+ warn.append(f"WARNING: cpp:{r} targets a {txtTargetType} (")
warn = sorted(warn)
for w in ws:
assert "targets a" in w
@@ -1326,7 +1326,7 @@ not found in `{test}`
for role in (expr_role, texpr_role):
name = role.name
- expect = '`{name}` puts the domain and role classes at its root'.format(name=name)
+ expect = f'`{name}` puts the domain and role classes at its root'
assert {'sig', 'sig-inline', 'cpp', name} <= role.classes, expect
# reference classes
diff --git a/tests/test_ext_apidoc.py b/tests/test_ext_apidoc.py
index 2d427417b..66b106fe6 100644
--- a/tests/test_ext_apidoc.py
+++ b/tests/test_ext_apidoc.py
@@ -318,7 +318,7 @@ def test_toc_all_references_should_exist_pep420_enabled(make_app, apidoc):
if ref and ref[0] in (':', '#'):
continue
found_refs.append(ref)
- filename = "{}.rst".format(ref)
+ filename = f"{ref}.rst"
if not (outdir / filename).isfile():
missing_files.append(filename)
@@ -347,7 +347,7 @@ def test_toc_all_references_should_exist_pep420_disabled(make_app, apidoc):
for ref in refs:
if ref and ref[0] in (':', '#'):
continue
- filename = "{}.rst".format(ref)
+ filename = f"{ref}.rst"
found_refs.append(ref)
if not (outdir / filename).isfile():
missing_files.append(filename)
diff --git a/tests/test_ext_doctest.py b/tests/test_ext_doctest.py
index 6c628904f..e03c12540 100644
--- a/tests/test_ext_doctest.py
+++ b/tests/test_ext_doctest.py
@@ -117,7 +117,7 @@ def test_skipif(app, status, warning):
def record(directive, part, should_skip):
global recorded_calls
recorded_calls[(directive, part, should_skip)] += 1
- return 'Recorded {} {} {}'.format(directive, part, should_skip)
+ return f'Recorded {directive} {part} {should_skip}'
@pytest.mark.sphinx('doctest', testroot='ext-doctest-with-autodoc')
diff --git a/tests/test_ext_imgconverter.py b/tests/test_ext_imgconverter.py
index 8b938a0dc..5132390cf 100644
--- a/tests/test_ext_imgconverter.py
+++ b/tests/test_ext_imgconverter.py
@@ -1,7 +1,6 @@
"""Test sphinx.ext.imgconverter extension."""
import subprocess
-from subprocess import PIPE
import pytest
@@ -11,7 +10,7 @@ def if_converter_found(app):
image_converter = getattr(app.config, 'image_converter', '')
try:
if image_converter:
- subprocess.run([image_converter, '-version'], stdout=PIPE, stderr=PIPE) # show version
+ subprocess.run([image_converter, '-version'], capture_output=True) # show version
return
except OSError: # No such file or directory
pass
diff --git a/tests/test_util_inspect.py b/tests/test_util_inspect.py
index bb43fb30d..753b363da 100644
--- a/tests/test_util_inspect.py
+++ b/tests/test_util_inspect.py
@@ -716,7 +716,7 @@ def test_getdoc_inherited_decorated_method():
"""
class Bar(Foo):
- @functools.lru_cache() # noqa: B019
+ @functools.lru_cache # noqa: B019
def meth(self):
# inherited and decorated method
pass