Fix flake8 violations on tests

This commit is contained in:
Takeshi KOMIYA 2018-07-28 20:19:30 +09:00
parent 8ddca8c620
commit f969edfaa8
12 changed files with 19 additions and 24 deletions

View File

@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
import os
import sys
extensions = ['sphinx.ext.viewcode']
master_doc = 'index'
exclude_patterns = ['_build']

View File

@ -3,6 +3,7 @@ submodule
"""
raise RuntimeError('This module should not get imported')
def decorator(f):
return f

View File

@ -1,4 +1,4 @@
"""
r"""
Test with a class diagram like this::

View File

@ -2,4 +2,3 @@
master_doc = 'equations'
extensions = ['sphinx.ext.imgmath']

View File

@ -12,7 +12,6 @@ import pytest
from docutils import nodes
from sphinx.errors import ExtensionError
from sphinx.domains import Domain
from sphinx.testing.util import strip_escseq
from sphinx.util import logging

View File

@ -1249,7 +1249,6 @@ def test_enum_class(app):
]
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_descriptor_class(app):
options = {"members": ['CustomDataDescriptor', 'CustomDataDescriptor2']}

View File

@ -175,8 +175,8 @@ def test_gettext_template_msgid_order_in_sphinxpot(app):
result = (app.outdir / 'sphinx.pot').text(encoding='utf-8')
assert re.search(
('msgid "Template 1".*'
'msgid "This is Template 1\.".*'
'msgid "This is Template 1\\.".*'
'msgid "Template 2".*'
'msgid "This is Template 2\.".*'),
'msgid "This is Template 2\\.".*'),
result,
flags=re.S)

View File

@ -172,20 +172,20 @@ def make_app_with_empty_project(make_app, tempdir):
def test_needs_sphinx(make_app_with_empty_project):
make_app = make_app_with_empty_project
# micro version
app = make_app(confoverrides={'needs_sphinx': '1.3.3'}) # OK: less
app = make_app(confoverrides={'needs_sphinx': '1.3.4'}) # OK: equals
make_app(confoverrides={'needs_sphinx': '1.3.3'}) # OK: less
make_app(confoverrides={'needs_sphinx': '1.3.4'}) # OK: equals
with pytest.raises(VersionRequirementError):
make_app(confoverrides={'needs_sphinx': '1.3.5'}) # NG: greater
# minor version
app = make_app(confoverrides={'needs_sphinx': '1.2'}) # OK: less
app = make_app(confoverrides={'needs_sphinx': '1.3'}) # OK: equals
make_app(confoverrides={'needs_sphinx': '1.2'}) # OK: less
make_app(confoverrides={'needs_sphinx': '1.3'}) # OK: equals
with pytest.raises(VersionRequirementError):
make_app(confoverrides={'needs_sphinx': '1.4'}) # NG: greater
# major version
app = make_app(confoverrides={'needs_sphinx': '0'}) # OK: less
app = make_app(confoverrides={'needs_sphinx': '1'}) # OK: equals
make_app(confoverrides={'needs_sphinx': '0'}) # OK: less
make_app(confoverrides={'needs_sphinx': '1'}) # OK: equals
with pytest.raises(VersionRequirementError):
make_app(confoverrides={'needs_sphinx': '2'}) # NG: greater

View File

@ -760,9 +760,9 @@ def test_xref_consistency(app, status, warning):
def classes(role, tag):
pattern = (r'{role}-role:.*?'
'<(?P<tag>{tag}) .*?class=["\'](?P<classes>.*?)["\'].*?>'
'.*'
'</(?P=tag)>').format(role=role, tag=tag)
r'<(?P<tag>{tag}) .*?class=["\'](?P<classes>.*?)["\'].*?>'
r'.*'
r'</(?P=tag)>').format(role=role, tag=tag)
result = re.search(pattern, output)
expect = '''\
Pattern for role `{role}` with tag `{tag}`
@ -783,17 +783,17 @@ not found in `{test}`
self.content_classes[tag] = classes(role, tag)
# not actually used as a reference point
#code_role = RoleClasses('code', 'code', [])
# code_role = RoleClasses('code', 'code', [])
any_role = RoleClasses('any', 'a', ['code'])
cpp_any_role = RoleClasses('cpp-any', 'a', ['code'])
# NYI: consistent looks
#texpr_role = RoleClasses('cpp-texpr', 'span', ['a', 'code'])
# texpr_role = RoleClasses('cpp-texpr', 'span', ['a', 'code'])
expr_role = RoleClasses('cpp-expr', 'code', ['a'])
texpr_role = RoleClasses('cpp-texpr', 'span', ['a', 'span'])
# XRefRole-style classes
## any and cpp:any do not put these classes at the root
# any and cpp:any do not put these classes at the root
# n.b. the generic any machinery finds the specific 'cpp-class' object type
expect = 'any uses XRefRole classes'

View File

@ -113,7 +113,8 @@ def test_glob(app):
maxdepth=-1, numbered=0, includefiles=includefiles,
entries=[(None, 'foo'), (None, 'bar/index'), (None, 'bar/bar_1'),
(None, 'bar/bar_2'), (None, 'bar/bar_3'), (None, 'baz'),
(None, 'qux/index'), ('hyperref', 'https://sphinx-doc.org/?q=sphinx')])
(None, 'qux/index'),
('hyperref', 'https://sphinx-doc.org/?q=sphinx')])
assert_node(toctree[0][1][1],
[list_item, ([compact_paragraph, reference, "reversed order"],
[bullet_list, addnodes.toctree])]) # [0][1][1][1][0]

View File

@ -387,8 +387,6 @@ def extract_toc(path):
coderoot='test-apidoc-subpackage-in-toc',
options=['--separate']
)
def test_subpackage_in_toc(make_app, apidoc):
"""Make sure that empty subpackages with non-empty subpackages in them
are not skipped (issue #4520)

View File

@ -9,6 +9,7 @@
:license: BSD, see LICENSE for details.
"""
import os
import pytest
from packaging.specifiers import InvalidSpecifier
from packaging.version import InvalidVersion