mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add return annotation to several zero-argument test functions
This commit is contained in:
@@ -138,7 +138,7 @@ def test_file_checksum(app):
|
||||
assert '<script src="https://example.com/script.js"></script>' in content
|
||||
|
||||
|
||||
def test_file_checksum_query_string():
|
||||
def test_file_checksum_query_string() -> None:
|
||||
with pytest.raises(
|
||||
ThemeError,
|
||||
match='Local asset file paths must not contain query strings',
|
||||
|
||||
@@ -96,7 +96,7 @@ end
|
||||
assert expected in content
|
||||
|
||||
|
||||
def test_default_man_pages():
|
||||
def test_default_man_pages() -> None:
|
||||
config = Config({
|
||||
'project': 'STASI™ Documentation',
|
||||
'author': "Wolfgang Schäuble & G'Beckstein",
|
||||
|
||||
@@ -64,7 +64,7 @@ def test_texinfo_citation(app):
|
||||
) in output
|
||||
|
||||
|
||||
def test_default_texinfo_documents():
|
||||
def test_default_texinfo_documents() -> None:
|
||||
config = Config({
|
||||
'project': 'STASI™ Documentation',
|
||||
'author': "Wolfgang Schäuble & G'Beckstein",
|
||||
|
||||
@@ -312,7 +312,7 @@ def test_extension_values():
|
||||
assert 'already present' in str(excinfo.value)
|
||||
|
||||
|
||||
def test_overrides():
|
||||
def test_overrides() -> None:
|
||||
config = Config(
|
||||
{'value1': '1', 'value2': 2, 'value6': {'default': 6}},
|
||||
{
|
||||
@@ -343,7 +343,7 @@ def test_overrides():
|
||||
assert config.value8 == ['abc', 'def', 'ghi']
|
||||
|
||||
|
||||
def test_overrides_boolean():
|
||||
def test_overrides_boolean() -> None:
|
||||
config = Config({}, {'value1': '1', 'value2': '0', 'value3': '0'})
|
||||
config.add('value1', None, 'env', [bool])
|
||||
config.add('value2', None, 'env', [bool])
|
||||
@@ -372,7 +372,7 @@ def test_overrides_dict_str(logger):
|
||||
)
|
||||
|
||||
|
||||
def test_callable_defer():
|
||||
def test_callable_defer() -> None:
|
||||
config = Config()
|
||||
config.add('alias', lambda c: c.master_doc, '', str)
|
||||
|
||||
@@ -725,7 +725,7 @@ def test_conf_py_nitpick_ignore_list(tmp_path):
|
||||
assert cfg.nitpick_ignore_regex == []
|
||||
|
||||
|
||||
def test_gettext_compact_command_line_true():
|
||||
def test_gettext_compact_command_line_true() -> None:
|
||||
config = Config({}, {'gettext_compact': '1'})
|
||||
config.add('gettext_compact', True, '', {bool, str})
|
||||
|
||||
@@ -734,7 +734,7 @@ def test_gettext_compact_command_line_true():
|
||||
assert config.gettext_compact is True
|
||||
|
||||
|
||||
def test_gettext_compact_command_line_false():
|
||||
def test_gettext_compact_command_line_false() -> None:
|
||||
config = Config({}, {'gettext_compact': '0'})
|
||||
config.add('gettext_compact', True, '', {bool, str})
|
||||
|
||||
@@ -743,7 +743,7 @@ def test_gettext_compact_command_line_false():
|
||||
assert config.gettext_compact is False
|
||||
|
||||
|
||||
def test_gettext_compact_command_line_str():
|
||||
def test_gettext_compact_command_line_str() -> None:
|
||||
config = Config({}, {'gettext_compact': 'spam'})
|
||||
config.add('gettext_compact', True, '', {bool, str})
|
||||
|
||||
@@ -752,7 +752,7 @@ def test_gettext_compact_command_line_str():
|
||||
assert config.gettext_compact == 'spam'
|
||||
|
||||
|
||||
def test_translation_progress_classes_command_line():
|
||||
def test_translation_progress_classes_command_line() -> None:
|
||||
config = Config({}, {'translation_progress_classes': '1'})
|
||||
|
||||
# regression test for --define translation_progress_classes=1
|
||||
@@ -760,7 +760,7 @@ def test_translation_progress_classes_command_line():
|
||||
assert config.translation_progress_classes is True
|
||||
|
||||
|
||||
def test_translation_progress_classes_command_line_false():
|
||||
def test_translation_progress_classes_command_line_false() -> None:
|
||||
config = Config({}, {'translation_progress_classes': '0'})
|
||||
|
||||
# regression test for --define translation_progress_classes=0
|
||||
@@ -768,7 +768,7 @@ def test_translation_progress_classes_command_line_false():
|
||||
assert config.translation_progress_classes is False
|
||||
|
||||
|
||||
def test_translation_progress_classes_command_line_str():
|
||||
def test_translation_progress_classes_command_line_str() -> None:
|
||||
config = Config({}, {'translation_progress_classes': 'translated'})
|
||||
|
||||
# regression test for --define translation_progress_classes=translated
|
||||
@@ -776,7 +776,7 @@ def test_translation_progress_classes_command_line_str():
|
||||
assert config.translation_progress_classes == 'translated'
|
||||
|
||||
|
||||
def test_autosummary_generate_command_line_false():
|
||||
def test_autosummary_generate_command_line_false() -> None:
|
||||
config = Config({}, {'autosummary_generate': '0'})
|
||||
config.add('autosummary_generate', True, '', {bool, list})
|
||||
|
||||
@@ -785,7 +785,7 @@ def test_autosummary_generate_command_line_false():
|
||||
assert config.autosummary_generate is False
|
||||
|
||||
|
||||
def test_boolean_command_line_invalid():
|
||||
def test_boolean_command_line_invalid() -> None:
|
||||
config = Config({}, {'rabit_of_caerbannog': ''})
|
||||
config.add('rabit_of_caerbannog', True, '', {bool})
|
||||
with pytest.raises(
|
||||
@@ -794,7 +794,7 @@ def test_boolean_command_line_invalid():
|
||||
_ = config.rabit_of_caerbannog
|
||||
|
||||
|
||||
def test_root_doc_and_master_doc_are_synchronized():
|
||||
def test_root_doc_and_master_doc_are_synchronized() -> None:
|
||||
c = Config()
|
||||
assert c.master_doc == 'index'
|
||||
assert c.root_doc == c.master_doc
|
||||
|
||||
@@ -135,7 +135,7 @@ def check(name, input, id_dict, output=None, key=None, as_text_output=None):
|
||||
)
|
||||
|
||||
|
||||
def test_domain_c_ast_expressions():
|
||||
def test_domain_c_ast_expressions() -> None:
|
||||
def expr_check(expr, output=None):
|
||||
parser = DefinitionParser(expr, location=None, config=Config())
|
||||
parser.allowFallbackExpressionParsing = False
|
||||
@@ -336,7 +336,7 @@ def test_domain_c_ast_expressions():
|
||||
expr_check('a or_eq 5')
|
||||
|
||||
|
||||
def test_domain_c_ast_fundamental_types():
|
||||
def test_domain_c_ast_fundamental_types() -> None:
|
||||
def types():
|
||||
def signed(t):
|
||||
yield t
|
||||
@@ -403,7 +403,7 @@ def test_domain_c_ast_fundamental_types():
|
||||
check('type', input, {1: 'foo'}, key='typedef', output=output)
|
||||
|
||||
|
||||
def test_domain_c_ast_type_definitions():
|
||||
def test_domain_c_ast_type_definitions() -> None:
|
||||
check('type', '{key}T', {1: 'T'})
|
||||
|
||||
check('type', '{key}bool *b', {1: 'b'}, key='typedef')
|
||||
@@ -429,7 +429,7 @@ def test_domain_c_ast_type_definitions():
|
||||
)
|
||||
|
||||
|
||||
def test_domain_c_ast_macro_definitions():
|
||||
def test_domain_c_ast_macro_definitions() -> None:
|
||||
check('macro', 'M', {1: 'M'})
|
||||
check('macro', 'M()', {1: 'M'})
|
||||
check('macro', 'M(arg)', {1: 'M'})
|
||||
@@ -445,7 +445,7 @@ def test_domain_c_ast_macro_definitions():
|
||||
check('macro', 'M(arg1, arg2..., arg3)', {1: 'M'})
|
||||
|
||||
|
||||
def test_domain_c_ast_member_definitions():
|
||||
def test_domain_c_ast_member_definitions() -> None:
|
||||
check('member', 'void a', {1: 'a'})
|
||||
check('member', '_Bool a', {1: 'a'})
|
||||
check('member', 'bool a', {1: 'a'})
|
||||
@@ -501,7 +501,7 @@ def test_domain_c_ast_member_definitions():
|
||||
check('member', 'int b : 3', {1: 'b'})
|
||||
|
||||
|
||||
def test_domain_c_ast_function_definitions():
|
||||
def test_domain_c_ast_function_definitions() -> None:
|
||||
check('function', 'void f()', {1: 'f'})
|
||||
check('function', 'void f(int)', {1: 'f'})
|
||||
check('function', 'void f(int i)', {1: 'f'})
|
||||
@@ -570,29 +570,29 @@ def test_domain_c_ast_function_definitions():
|
||||
check('function', 'void f(void (*p)(int, double), int i)', {1: 'f'})
|
||||
|
||||
|
||||
def test_domain_c_ast_nested_name():
|
||||
def test_domain_c_ast_nested_name() -> None:
|
||||
check('struct', '{key}.A', {1: 'A'})
|
||||
check('struct', '{key}.A.B', {1: 'A.B'})
|
||||
check('function', 'void f(.A a)', {1: 'f'})
|
||||
check('function', 'void f(.A.B a)', {1: 'f'})
|
||||
|
||||
|
||||
def test_domain_c_ast_struct_definitions():
|
||||
def test_domain_c_ast_struct_definitions() -> None:
|
||||
check('struct', '{key}A', {1: 'A'})
|
||||
|
||||
|
||||
def test_domain_c_ast_union_definitions():
|
||||
def test_domain_c_ast_union_definitions() -> None:
|
||||
check('union', '{key}A', {1: 'A'})
|
||||
|
||||
|
||||
def test_domain_c_ast_enum_definitions():
|
||||
def test_domain_c_ast_enum_definitions() -> None:
|
||||
check('enum', '{key}A', {1: 'A'})
|
||||
|
||||
check('enumerator', '{key}A', {1: 'A'})
|
||||
check('enumerator', '{key}A = 42', {1: 'A'})
|
||||
|
||||
|
||||
def test_domain_c_ast_anon_definitions():
|
||||
def test_domain_c_ast_anon_definitions() -> None:
|
||||
check('struct', '@a', {1: '@a'}, as_text_output='struct [anonymous]')
|
||||
check('union', '@a', {1: '@a'}, as_text_output='union [anonymous]')
|
||||
check('enum', '@a', {1: '@a'}, as_text_output='enum [anonymous]')
|
||||
@@ -600,7 +600,7 @@ def test_domain_c_ast_anon_definitions():
|
||||
check('struct', '@a.A', {1: '@a.A'}, as_text_output='struct [anonymous].A')
|
||||
|
||||
|
||||
def test_domain_c_ast_initializers():
|
||||
def test_domain_c_ast_initializers() -> None:
|
||||
ids_member = {1: 'v'}
|
||||
ids_function = {1: 'f'}
|
||||
# no init
|
||||
@@ -619,7 +619,7 @@ def test_domain_c_ast_initializers():
|
||||
# TODO: designator-list
|
||||
|
||||
|
||||
def test_domain_c_ast_attributes():
|
||||
def test_domain_c_ast_attributes() -> None:
|
||||
# style: C++
|
||||
check('member', '[[]] int f', {1: 'f'})
|
||||
check(
|
||||
@@ -688,12 +688,12 @@ def test_domain_c_ast_attributes():
|
||||
)
|
||||
|
||||
|
||||
def test_extra_keywords():
|
||||
def test_extra_keywords() -> None:
|
||||
with pytest.raises(DefinitionError, match='Expected identifier in nested name'):
|
||||
parse('function', 'void complex(void)')
|
||||
|
||||
|
||||
# def test_print():
|
||||
# def test_print() -> None:
|
||||
# # used for getting all the ids out for checking
|
||||
# for a in ids:
|
||||
# print(a)
|
||||
|
||||
@@ -176,7 +176,7 @@ def test_domain_cpp_ast_fundamental_types(type_, id_v2):
|
||||
check('function', input, {1: id1, 2: id2})
|
||||
|
||||
|
||||
def test_domain_cpp_ast_expressions():
|
||||
def test_domain_cpp_ast_expressions() -> None:
|
||||
def expr_check(expr, id, id4=None):
|
||||
ids = 'IE1CIA%s_1aE'
|
||||
# call .format() on the expr to unescape double curly braces
|
||||
@@ -450,7 +450,7 @@ def test_domain_cpp_ast_expressions():
|
||||
expr_check('a(b(c, 1 + d...)..., e(f..., g))', 'cl1aspcl1b1cspplL1E1dEcl1esp1f1gEE')
|
||||
|
||||
|
||||
def test_domain_cpp_ast_type_definitions():
|
||||
def test_domain_cpp_ast_type_definitions() -> None:
|
||||
check('type', 'public bool b', {1: 'b', 2: '1b'}, '{key}bool b', key='typedef')
|
||||
check('type', '{key}bool A::b', {1: 'A::b', 2: 'N1A1bE'}, key='typedef')
|
||||
check('type', '{key}bool *b', {1: 'b', 2: '1b'}, key='typedef')
|
||||
@@ -530,7 +530,7 @@ def test_domain_cpp_ast_type_definitions():
|
||||
check('type', '{key}T = Q<A::operator bool>', {2: '1T'}, key='using')
|
||||
|
||||
|
||||
def test_domain_cpp_ast_concept_definitions():
|
||||
def test_domain_cpp_ast_concept_definitions() -> None:
|
||||
check(
|
||||
'concept',
|
||||
'template<typename Param> {key}A::B::Concept',
|
||||
@@ -547,7 +547,7 @@ def test_domain_cpp_ast_concept_definitions():
|
||||
parse('concept', 'template<typename T> template<typename U> {key}Foo')
|
||||
|
||||
|
||||
def test_domain_cpp_ast_member_definitions():
|
||||
def test_domain_cpp_ast_member_definitions() -> None:
|
||||
check(
|
||||
'member',
|
||||
' const std::string & name = 42',
|
||||
@@ -598,7 +598,7 @@ def test_domain_cpp_ast_member_definitions():
|
||||
check('member', 'constinit int n', {1: 'n__i', 2: '1n'})
|
||||
|
||||
|
||||
def test_domain_cpp_ast_function_definitions():
|
||||
def test_domain_cpp_ast_function_definitions() -> None:
|
||||
check('function', 'void f(volatile int)', {1: 'f__iV', 2: '1fVi'})
|
||||
check('function', 'void f(std::size_t)', {1: 'f__std::s', 2: '1fNSt6size_tE'})
|
||||
check('function', 'operator bool() const', {1: 'castto-b-operatorC', 2: 'NKcvbEv'})
|
||||
@@ -928,7 +928,7 @@ def test_domain_cpp_ast_function_definitions():
|
||||
check('function', 'void f(void (*p)(int) = &foo)', {2: '1fPFviE'})
|
||||
|
||||
|
||||
def test_domain_cpp_ast_operators():
|
||||
def test_domain_cpp_ast_operators() -> None:
|
||||
check('function', 'void operator new()', {1: 'new-operator', 2: 'nwv'})
|
||||
check('function', 'void operator new[]()', {1: 'new-array-operator', 2: 'nav'})
|
||||
check('function', 'void operator delete()', {1: 'delete-operator', 2: 'dlv'})
|
||||
@@ -992,14 +992,14 @@ def test_domain_cpp_ast_operators():
|
||||
check('function', 'void operator[]()', {1: 'subscript-operator', 2: 'ixv'})
|
||||
|
||||
|
||||
def test_domain_cpp_ast_nested_name():
|
||||
def test_domain_cpp_ast_nested_name() -> None:
|
||||
check('class', '{key}::A', {1: 'A', 2: '1A'})
|
||||
check('class', '{key}::A::B', {1: 'A::B', 2: 'N1A1BE'})
|
||||
check('function', 'void f(::A a)', {1: 'f__A', 2: '1f1A'})
|
||||
check('function', 'void f(::A::B a)', {1: 'f__A::B', 2: '1fN1A1BE'})
|
||||
|
||||
|
||||
def test_domain_cpp_ast_class_definitions():
|
||||
def test_domain_cpp_ast_class_definitions() -> None:
|
||||
check('class', 'public A', {1: 'A', 2: '1A'}, output='{key}A')
|
||||
check('class', 'private {key}A', {1: 'A', 2: '1A'})
|
||||
check('class', '{key}A final', {1: 'A', 2: '1A'})
|
||||
@@ -1048,11 +1048,11 @@ def test_domain_cpp_ast_class_definitions():
|
||||
)
|
||||
|
||||
|
||||
def test_domain_cpp_ast_union_definitions():
|
||||
def test_domain_cpp_ast_union_definitions() -> None:
|
||||
check('union', '{key}A', {2: '1A'})
|
||||
|
||||
|
||||
def test_domain_cpp_ast_enum_definitions():
|
||||
def test_domain_cpp_ast_enum_definitions() -> None:
|
||||
check('enum', '{key}A', {2: '1A'})
|
||||
check('enum', '{key}A : std::underlying_type<B>::type', {2: '1A'})
|
||||
check('enum', '{key}A : unsigned int', {2: '1A'})
|
||||
@@ -1063,7 +1063,7 @@ def test_domain_cpp_ast_enum_definitions():
|
||||
check('enumerator', '{key}A = std::numeric_limits<unsigned long>::max()', {2: '1A'})
|
||||
|
||||
|
||||
def test_domain_cpp_ast_anon_definitions():
|
||||
def test_domain_cpp_ast_anon_definitions() -> None:
|
||||
check('class', '@a', {3: 'Ut1_a'}, as_text_output='class [anonymous]')
|
||||
check('union', '@a', {3: 'Ut1_a'}, as_text_output='union [anonymous]')
|
||||
check('enum', '@a', {3: 'Ut1_a'}, as_text_output='enum [anonymous]')
|
||||
@@ -1078,7 +1078,7 @@ def test_domain_cpp_ast_anon_definitions():
|
||||
)
|
||||
|
||||
|
||||
def test_domain_cpp_ast_templates():
|
||||
def test_domain_cpp_ast_templates() -> None:
|
||||
check('class', 'A<T>', {2: 'IE1AI1TE'}, output='template<> {key}A<T>')
|
||||
# first just check which objects support templating
|
||||
check('class', 'template<> {key}A', {2: 'IE1A'})
|
||||
@@ -1268,7 +1268,7 @@ def test_domain_cpp_ast_templates():
|
||||
)
|
||||
|
||||
|
||||
def test_domain_cpp_ast_placeholder_types():
|
||||
def test_domain_cpp_ast_placeholder_types() -> None:
|
||||
check(
|
||||
'function', 'void f(Sortable auto &v)', {1: 'f__SortableR', 2: '1fR8Sortable'}
|
||||
)
|
||||
@@ -1295,7 +1295,7 @@ def test_domain_cpp_ast_placeholder_types():
|
||||
)
|
||||
|
||||
|
||||
def test_domain_cpp_ast_requires_clauses():
|
||||
def test_domain_cpp_ast_requires_clauses() -> None:
|
||||
check(
|
||||
'function',
|
||||
'template<typename T> requires A auto f() -> void requires B',
|
||||
@@ -1350,7 +1350,7 @@ def test_domain_cpp_ast_requires_clauses():
|
||||
)
|
||||
|
||||
|
||||
def test_domain_cpp_ast_template_args():
|
||||
def test_domain_cpp_ast_template_args() -> None:
|
||||
# from https://github.com/breathe-doc/breathe/issues/218
|
||||
check(
|
||||
'function',
|
||||
@@ -1371,7 +1371,7 @@ def test_domain_cpp_ast_template_args():
|
||||
)
|
||||
|
||||
|
||||
def test_domain_cpp_ast_initializers():
|
||||
def test_domain_cpp_ast_initializers() -> None:
|
||||
ids_member = {1: 'v__T', 2: '1v'}
|
||||
ids_function = {1: 'f__T', 2: '1f1T'}
|
||||
ids_template = {2: 'I_1TE1fv', 4: 'I_1TE1fvv'}
|
||||
@@ -1405,7 +1405,7 @@ def test_domain_cpp_ast_initializers():
|
||||
check('member', 'T v = T{}', ids_member)
|
||||
|
||||
|
||||
def test_domain_cpp_ast_attributes():
|
||||
def test_domain_cpp_ast_attributes() -> None:
|
||||
# style: C++
|
||||
check('member', '[[]] int f', {1: 'f__i', 2: '1f'})
|
||||
check(
|
||||
@@ -1482,7 +1482,7 @@ def check_ast_xref_parsing(target):
|
||||
parser.assert_end()
|
||||
|
||||
|
||||
def test_domain_cpp_ast_xref_parsing():
|
||||
def test_domain_cpp_ast_xref_parsing() -> None:
|
||||
check_ast_xref_parsing('f')
|
||||
check_ast_xref_parsing('f()')
|
||||
check_ast_xref_parsing('void f()')
|
||||
@@ -1524,7 +1524,7 @@ def test_domain_cpp_template_parameters_is_pack(param: str, is_pack: bool):
|
||||
assert ast.isPack == is_pack
|
||||
|
||||
|
||||
# def test_print():
|
||||
# def test_print() -> None:
|
||||
# # used for getting all the ids out for checking
|
||||
# for a in ids:
|
||||
# print(a)
|
||||
|
||||
@@ -173,7 +173,7 @@ def test_domain_js_find_obj(app):
|
||||
) == ('module_a.submodule', ('module', 'module-module_a.submodule', 'module'))
|
||||
|
||||
|
||||
def test_get_full_qualified_name():
|
||||
def test_get_full_qualified_name() -> None:
|
||||
env = Mock(domaindata={})
|
||||
domain = JavaScriptDomain(env)
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ def parse(sig):
|
||||
return signode.astext()
|
||||
|
||||
|
||||
def test_function_signatures():
|
||||
def test_function_signatures() -> None:
|
||||
rv = parse("compile(source : string, filename, symbol='file')")
|
||||
assert rv == "(source : string, filename, symbol='file')"
|
||||
|
||||
@@ -321,7 +321,7 @@ def test_domain_py_find_obj(app):
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='root')
|
||||
def test_get_full_qualified_name():
|
||||
def test_get_full_qualified_name() -> None:
|
||||
env = Mock(domaindata={})
|
||||
domain = PythonDomain(env)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ from sphinx.testing import restructuredtext
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
|
||||
def test_parse_directive():
|
||||
def test_parse_directive() -> None:
|
||||
s = parse_directive(' foö ')
|
||||
assert s == ('foö', '')
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ from sphinx.testing import restructuredtext
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
|
||||
def test_process_doc_handle_figure_caption():
|
||||
def test_process_doc_handle_figure_caption() -> None:
|
||||
env = mock.Mock(domaindata={})
|
||||
env.app.registry.enumerable_nodes = {}
|
||||
figure_node = nodes.figure(
|
||||
@@ -47,7 +47,7 @@ def test_process_doc_handle_figure_caption():
|
||||
assert domain.data['labels']['testname'] == ('testdoc', 'testid', 'caption text')
|
||||
|
||||
|
||||
def test_process_doc_handle_table_title():
|
||||
def test_process_doc_handle_table_title() -> None:
|
||||
env = mock.Mock(domaindata={})
|
||||
env.app.registry.enumerable_nodes = {}
|
||||
table_node = nodes.table(
|
||||
@@ -70,7 +70,7 @@ def test_process_doc_handle_table_title():
|
||||
assert domain.data['labels']['testname'] == ('testdoc', 'testid', 'title text')
|
||||
|
||||
|
||||
def test_get_full_qualified_name():
|
||||
def test_get_full_qualified_name() -> None:
|
||||
env = mock.Mock(domaindata={})
|
||||
env.app.registry.enumerable_nodes = {}
|
||||
domain = StandardDomain(env)
|
||||
|
||||
@@ -196,7 +196,7 @@ def test_env_relfn2path(app):
|
||||
app.env.relfn2path('images/logo.jpg')
|
||||
|
||||
|
||||
def test_differing_config_keys():
|
||||
def test_differing_config_keys() -> None:
|
||||
diff = _differing_config_keys
|
||||
|
||||
old = Config({'project': 'old'})
|
||||
|
||||
@@ -3,11 +3,11 @@ from __future__ import annotations
|
||||
from sphinx.errors import ExtensionError
|
||||
|
||||
|
||||
def test_extension_error_repr():
|
||||
def test_extension_error_repr() -> None:
|
||||
exc = ExtensionError('foo')
|
||||
assert repr(exc) == "ExtensionError('foo')"
|
||||
|
||||
|
||||
def test_extension_error_with_orig_exc_repr():
|
||||
def test_extension_error_with_orig_exc_repr() -> None:
|
||||
exc = ExtensionError('foo', Exception('bar'))
|
||||
assert repr(exc) == "ExtensionError('foo', Exception('bar'))"
|
||||
|
||||
@@ -10,7 +10,7 @@ from sphinx.errors import ExtensionError
|
||||
from sphinx.events import EventManager
|
||||
|
||||
|
||||
def test_event_priority():
|
||||
def test_event_priority() -> None:
|
||||
result = []
|
||||
app = object() # pass a dummy object as an app
|
||||
events = EventManager(app) # type: ignore[arg-type]
|
||||
@@ -26,7 +26,7 @@ def test_event_priority():
|
||||
assert result == [3, 1, 2, 5, 4]
|
||||
|
||||
|
||||
def test_event_allowed_exceptions():
|
||||
def test_event_allowed_exceptions() -> None:
|
||||
def raise_error(app):
|
||||
raise RuntimeError
|
||||
|
||||
@@ -43,7 +43,7 @@ def test_event_allowed_exceptions():
|
||||
events.emit('builder-inited', allowed_exceptions=(RuntimeError,))
|
||||
|
||||
|
||||
def test_event_pdb():
|
||||
def test_event_pdb() -> None:
|
||||
def raise_error(app):
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import pytest
|
||||
from sphinx.ext.autodoc.mock import _MockModule, _MockObject, ismock, mock, undecorate
|
||||
|
||||
|
||||
def test_MockModule():
|
||||
def test_MockModule() -> None:
|
||||
mock = _MockModule('mocked_module')
|
||||
assert isinstance(mock.some_attr, _MockObject)
|
||||
assert isinstance(mock.some_method, _MockObject)
|
||||
@@ -58,7 +58,7 @@ def test_MockObject():
|
||||
assert isinstance(obj2, SubClass2)
|
||||
|
||||
|
||||
def test_mock():
|
||||
def test_mock() -> None:
|
||||
modname = 'sphinx.unknown'
|
||||
submodule = modname + '.submodule'
|
||||
assert modname not in sys.modules
|
||||
@@ -80,7 +80,7 @@ def test_mock():
|
||||
import_module(modname)
|
||||
|
||||
|
||||
def test_mock_does_not_follow_upper_modules():
|
||||
def test_mock_does_not_follow_upper_modules() -> None:
|
||||
with mock(['sphinx.unknown.module']): # NoQA: SIM117
|
||||
with pytest.raises(ImportError):
|
||||
import_module('sphinx.unknown')
|
||||
|
||||
@@ -46,7 +46,7 @@ def _unload_target_module():
|
||||
sys.modules.pop('target', None)
|
||||
|
||||
|
||||
def test_mangle_signature():
|
||||
def test_mangle_signature() -> None:
|
||||
TEST_SIGNATURE = """
|
||||
() :: ()
|
||||
(a, b, c, d, e) :: (a, b, c, d, e)
|
||||
@@ -775,7 +775,7 @@ def test_autosummary_latex_table_colspec(app):
|
||||
assert r'p{0.5\linewidth}' not in result
|
||||
|
||||
|
||||
def test_import_by_name():
|
||||
def test_import_by_name() -> None:
|
||||
import sphinx
|
||||
import sphinx.ext.autosummary
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ def test_highlight_language_python3(app):
|
||||
assert node['language'] in {'python', 'pycon', 'none'}
|
||||
|
||||
|
||||
def test_is_allowed_version():
|
||||
def test_is_allowed_version() -> None:
|
||||
assert is_allowed_version('<3.4', '3.3') is True
|
||||
assert is_allowed_version('<3.4', '3.3') is True
|
||||
assert is_allowed_version('<3.2', '3.3') is False
|
||||
|
||||
@@ -159,7 +159,7 @@ def test_graphviz_i18n(app):
|
||||
assert re.search(html, content, re.MULTILINE)
|
||||
|
||||
|
||||
def test_graphviz_parse_mapfile():
|
||||
def test_graphviz_parse_mapfile() -> None:
|
||||
# empty graph
|
||||
code = '# digraph {\n# }\n'
|
||||
content = '<map id="%3" name="%3">\n</map>'
|
||||
|
||||
@@ -626,7 +626,7 @@ class TestStripBasicAuth:
|
||||
assert actual == expected
|
||||
|
||||
|
||||
def test_getsafeurl_authed():
|
||||
def test_getsafeurl_authed() -> None:
|
||||
"""_get_safe_url() with a url with basic auth"""
|
||||
url = 'https://user:12345@domain.com/project/objects.inv'
|
||||
expected = 'https://user@domain.com/project/objects.inv'
|
||||
@@ -634,7 +634,7 @@ def test_getsafeurl_authed():
|
||||
assert actual == expected
|
||||
|
||||
|
||||
def test_getsafeurl_authed_having_port():
|
||||
def test_getsafeurl_authed_having_port() -> None:
|
||||
"""_get_safe_url() with a url with basic auth having port"""
|
||||
url = 'https://user:12345@domain.com:8080/project/objects.inv'
|
||||
expected = 'https://user@domain.com:8080/project/objects.inv'
|
||||
@@ -642,7 +642,7 @@ def test_getsafeurl_authed_having_port():
|
||||
assert actual == expected
|
||||
|
||||
|
||||
def test_getsafeurl_unauthed():
|
||||
def test_getsafeurl_unauthed() -> None:
|
||||
"""_get_safe_url() with a url without basic auth"""
|
||||
url = 'https://domain.com/project/objects.inv'
|
||||
expected = 'https://domain.com/project/objects.inv'
|
||||
|
||||
@@ -218,7 +218,7 @@ def make_inventory_handler(
|
||||
return InventoryHandler
|
||||
|
||||
|
||||
def test_intersphinx_project_fixture():
|
||||
def test_intersphinx_project_fixture() -> None:
|
||||
# check that our fixture class is correct
|
||||
project = SingleEntryProject(1, 'route')
|
||||
assert project.url == 'http://localhost:9341/route'
|
||||
|
||||
@@ -49,7 +49,7 @@ def test_add_lexer(app):
|
||||
assert '<span class="n">a</span>b' in ret
|
||||
|
||||
|
||||
def test_detect_interactive():
|
||||
def test_detect_interactive() -> None:
|
||||
bridge = ComplainOnUnhighlighted('html')
|
||||
blocks = [
|
||||
"""
|
||||
@@ -62,13 +62,13 @@ def test_detect_interactive():
|
||||
assert ret.startswith('<div class="highlight">')
|
||||
|
||||
|
||||
def test_lexer_options():
|
||||
def test_lexer_options() -> None:
|
||||
bridge = PygmentsBridge('html')
|
||||
ret = bridge.highlight_block('//comment', 'php', opts={'startinline': True})
|
||||
assert '<span class="c1">//comment</span>' in ret
|
||||
|
||||
|
||||
def test_set_formatter():
|
||||
def test_set_formatter() -> None:
|
||||
PygmentsBridge.html_formatter = MyFormatter
|
||||
try:
|
||||
bridge = PygmentsBridge('html')
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from importlib.machinery import SourceFileLoader
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -14,7 +15,8 @@ from sphinx.pycode import ModuleAnalyzer
|
||||
SPHINX_MODULE_PATH = Path(sphinx.__file__).resolve().with_suffix('.py')
|
||||
|
||||
|
||||
def test_ModuleAnalyzer_get_module_source():
|
||||
def test_ModuleAnalyzer_get_module_source() -> None:
|
||||
assert isinstance(sphinx.__spec__.loader, SourceFileLoader) # type checking
|
||||
assert ModuleAnalyzer.get_module_source('sphinx') == (
|
||||
Path(sphinx.__file__),
|
||||
sphinx.__spec__.loader.get_source('sphinx'),
|
||||
@@ -27,16 +29,16 @@ def test_ModuleAnalyzer_get_module_source():
|
||||
ModuleAnalyzer.get_module_source('itertools')
|
||||
|
||||
|
||||
def test_ModuleAnalyzer_for_string():
|
||||
def test_ModuleAnalyzer_for_string() -> None:
|
||||
analyzer = ModuleAnalyzer.for_string('print("Hello world")', 'module_name')
|
||||
assert analyzer.modname == 'module_name'
|
||||
assert analyzer.srcname == '<string>'
|
||||
|
||||
|
||||
def test_ModuleAnalyzer_for_file():
|
||||
analyzer = ModuleAnalyzer.for_string(SPHINX_MODULE_PATH, 'sphinx')
|
||||
def test_ModuleAnalyzer_for_file() -> None:
|
||||
analyzer = ModuleAnalyzer.for_file(SPHINX_MODULE_PATH, 'sphinx')
|
||||
assert analyzer.modname == 'sphinx'
|
||||
assert analyzer.srcname == '<string>'
|
||||
assert analyzer.srcname == str(SPHINX_MODULE_PATH)
|
||||
|
||||
|
||||
def test_ModuleAnalyzer_for_module(rootdir):
|
||||
@@ -54,7 +56,7 @@ def test_ModuleAnalyzer_for_module(rootdir):
|
||||
sys.path[:] = saved_path
|
||||
|
||||
|
||||
def test_ModuleAnalyzer_find_tags():
|
||||
def test_ModuleAnalyzer_find_tags() -> None:
|
||||
code = (
|
||||
'class Foo(object):\n' # line: 1
|
||||
' """class Foo!"""\n'
|
||||
@@ -108,7 +110,7 @@ def test_ModuleAnalyzer_find_tags():
|
||||
assert tags['Corge.grault'] == ('def', 24, 27)
|
||||
|
||||
|
||||
def test_ModuleAnalyzer_find_attr_docs():
|
||||
def test_ModuleAnalyzer_find_attr_docs() -> None:
|
||||
code = (
|
||||
'class Foo(object):\n'
|
||||
' """class Foo!"""\n'
|
||||
@@ -180,7 +182,7 @@ def test_ModuleAnalyzer_find_attr_docs():
|
||||
}
|
||||
|
||||
|
||||
def test_ModuleAnalyzer_find_attr_docs_for_posonlyargs_method():
|
||||
def test_ModuleAnalyzer_find_attr_docs_for_posonlyargs_method() -> None:
|
||||
code = (
|
||||
'class Foo(object):\n'
|
||||
' def __init__(self, /):\n'
|
||||
|
||||
@@ -69,5 +69,5 @@ def test_unparse(source, expected):
|
||||
assert ast_unparse(module.body[0].value, source) == expected
|
||||
|
||||
|
||||
def test_unparse_None():
|
||||
def test_unparse_None() -> None:
|
||||
assert ast_unparse(None) is None
|
||||
|
||||
@@ -6,7 +6,7 @@ from sphinx.pycode.parser import Parser
|
||||
from sphinx.util.inspect import signature_from_str
|
||||
|
||||
|
||||
def test_comment_picker_basic():
|
||||
def test_comment_picker_basic() -> None:
|
||||
source = (
|
||||
'a = 1 + 1 #: assignment\n'
|
||||
'b = 1 +\\\n 1 #: assignment including a CR\n'
|
||||
@@ -30,7 +30,7 @@ def test_comment_picker_basic():
|
||||
}
|
||||
|
||||
|
||||
def test_comment_picker_location():
|
||||
def test_comment_picker_location() -> None:
|
||||
# multiple "before" comments
|
||||
source = (
|
||||
'#: comment before assignment1\n#:\n#: comment before assignment2\na = 1 + 1\n'
|
||||
@@ -90,7 +90,7 @@ def test_comment_picker_location():
|
||||
}
|
||||
|
||||
|
||||
def test_annotated_assignment():
|
||||
def test_annotated_assignment() -> None:
|
||||
source = (
|
||||
'a: str = "Sphinx" #: comment\n'
|
||||
'b: int = 1\n'
|
||||
@@ -116,7 +116,7 @@ def test_annotated_assignment():
|
||||
assert parser.definitions == {}
|
||||
|
||||
|
||||
def test_complex_assignment():
|
||||
def test_complex_assignment() -> None:
|
||||
source = (
|
||||
'a = 1 + 1; b = a #: compound statement\n'
|
||||
'c, d = (1, 1) #: unpack assignment\n'
|
||||
@@ -151,7 +151,7 @@ def test_complex_assignment():
|
||||
assert parser.definitions == {}
|
||||
|
||||
|
||||
def test_assignment_in_try_clause():
|
||||
def test_assignment_in_try_clause() -> None:
|
||||
source = (
|
||||
'try:\n'
|
||||
' a = None #: comment\n'
|
||||
@@ -166,7 +166,7 @@ def test_assignment_in_try_clause():
|
||||
assert parser.deforders == {'a': 0, 'c': 1}
|
||||
|
||||
|
||||
def test_obj_assignment():
|
||||
def test_obj_assignment() -> None:
|
||||
source = (
|
||||
'obj = SomeObject() #: some object\n'
|
||||
'obj.attr = 1 #: attr1\n'
|
||||
@@ -178,7 +178,7 @@ def test_obj_assignment():
|
||||
assert parser.definitions == {}
|
||||
|
||||
|
||||
def test_container_assignment():
|
||||
def test_container_assignment() -> None:
|
||||
source = (
|
||||
'l = [] #: list\n'
|
||||
'l[1] = True #: list assignment\n'
|
||||
@@ -193,7 +193,7 @@ def test_container_assignment():
|
||||
assert parser.definitions == {}
|
||||
|
||||
|
||||
def test_function():
|
||||
def test_function() -> None:
|
||||
source = (
|
||||
'def some_function():\n'
|
||||
' """docstring"""\n'
|
||||
@@ -208,7 +208,7 @@ def test_function():
|
||||
assert parser.deforders == {'some_function': 0}
|
||||
|
||||
|
||||
def test_nested_function():
|
||||
def test_nested_function() -> None:
|
||||
source = (
|
||||
'def some_function():\n'
|
||||
' a = 1 + 1 #: comment1\n'
|
||||
@@ -223,7 +223,7 @@ def test_nested_function():
|
||||
assert parser.deforders == {'some_function': 0}
|
||||
|
||||
|
||||
def test_class():
|
||||
def test_class() -> None:
|
||||
source = (
|
||||
'class Foo(object):\n'
|
||||
' attr1 = None #: comment1\n'
|
||||
@@ -259,7 +259,7 @@ def test_class():
|
||||
}
|
||||
|
||||
|
||||
def test_class_uses_non_self():
|
||||
def test_class_uses_non_self() -> None:
|
||||
source = (
|
||||
'class Foo(object):\n'
|
||||
' def __init__(this):\n'
|
||||
@@ -272,7 +272,7 @@ def test_class_uses_non_self():
|
||||
assert parser.deforders == {'Foo': 0, 'Foo.__init__': 1, 'Foo.a': 2}
|
||||
|
||||
|
||||
def test_nested_class():
|
||||
def test_nested_class() -> None:
|
||||
source = (
|
||||
'class Foo(object):\n'
|
||||
' attr1 = None #: comment1\n'
|
||||
@@ -295,7 +295,7 @@ def test_nested_class():
|
||||
}
|
||||
|
||||
|
||||
def test_class_comment():
|
||||
def test_class_comment() -> None:
|
||||
source = (
|
||||
'import logging\n'
|
||||
'logger = logging.getLogger(__name__)\n'
|
||||
@@ -309,7 +309,7 @@ def test_class_comment():
|
||||
assert parser.definitions == {'Foo': ('class', 4, 5)}
|
||||
|
||||
|
||||
def test_comment_picker_multiline_string():
|
||||
def test_comment_picker_multiline_string() -> None:
|
||||
source = (
|
||||
'class Foo(object):\n'
|
||||
' a = None\n'
|
||||
@@ -331,7 +331,7 @@ def test_comment_picker_multiline_string():
|
||||
}
|
||||
|
||||
|
||||
def test_decorators():
|
||||
def test_decorators() -> None:
|
||||
source = (
|
||||
'@deco\n'
|
||||
'def func1(): pass\n'
|
||||
@@ -360,7 +360,7 @@ def test_decorators():
|
||||
}
|
||||
|
||||
|
||||
def test_async_function_and_method():
|
||||
def test_async_function_and_method() -> None:
|
||||
source = (
|
||||
'async def some_function():\n'
|
||||
' """docstring"""\n'
|
||||
@@ -379,7 +379,7 @@ def test_async_function_and_method():
|
||||
}
|
||||
|
||||
|
||||
def test_imports():
|
||||
def test_imports() -> None:
|
||||
source = (
|
||||
'import sys\n'
|
||||
'from os import environment, path\n'
|
||||
@@ -399,14 +399,14 @@ def test_imports():
|
||||
}
|
||||
|
||||
|
||||
def test_formfeed_char():
|
||||
def test_formfeed_char() -> None:
|
||||
source = 'class Foo:\n\f\n attr = 1234 #: comment\n'
|
||||
parser = Parser(source)
|
||||
parser.parse()
|
||||
assert parser.comments == {('Foo', 'attr'): 'comment'}
|
||||
|
||||
|
||||
def test_typing_final():
|
||||
def test_typing_final() -> None:
|
||||
source = (
|
||||
'import typing\n'
|
||||
'\n'
|
||||
@@ -424,7 +424,7 @@ def test_typing_final():
|
||||
assert parser.finals == ['func', 'Foo', 'Foo.meth']
|
||||
|
||||
|
||||
def test_typing_final_from_import():
|
||||
def test_typing_final_from_import() -> None:
|
||||
source = (
|
||||
'from typing import final\n'
|
||||
'\n'
|
||||
@@ -442,7 +442,7 @@ def test_typing_final_from_import():
|
||||
assert parser.finals == ['func', 'Foo', 'Foo.meth']
|
||||
|
||||
|
||||
def test_typing_final_import_as():
|
||||
def test_typing_final_import_as() -> None:
|
||||
source = (
|
||||
'import typing as foo\n'
|
||||
'\n'
|
||||
@@ -460,7 +460,7 @@ def test_typing_final_import_as():
|
||||
assert parser.finals == ['func', 'Foo']
|
||||
|
||||
|
||||
def test_typing_final_from_import_as():
|
||||
def test_typing_final_from_import_as() -> None:
|
||||
source = (
|
||||
'from typing import final as bar\n'
|
||||
'\n'
|
||||
@@ -478,7 +478,7 @@ def test_typing_final_from_import_as():
|
||||
assert parser.finals == ['func', 'Foo']
|
||||
|
||||
|
||||
def test_typing_final_not_imported():
|
||||
def test_typing_final_not_imported() -> None:
|
||||
source = (
|
||||
'@typing.final\n'
|
||||
'def func(): pass\n'
|
||||
@@ -494,7 +494,7 @@ def test_typing_final_not_imported():
|
||||
assert parser.finals == []
|
||||
|
||||
|
||||
def test_typing_overload():
|
||||
def test_typing_overload() -> None:
|
||||
source = (
|
||||
'import typing\n'
|
||||
'\n'
|
||||
@@ -516,7 +516,7 @@ def test_typing_overload():
|
||||
}
|
||||
|
||||
|
||||
def test_typing_overload_from_import():
|
||||
def test_typing_overload_from_import() -> None:
|
||||
source = (
|
||||
'from typing import overload\n'
|
||||
'\n'
|
||||
@@ -538,7 +538,7 @@ def test_typing_overload_from_import():
|
||||
}
|
||||
|
||||
|
||||
def test_typing_overload_import_as():
|
||||
def test_typing_overload_import_as() -> None:
|
||||
source = (
|
||||
'import typing as foo\n'
|
||||
'\n'
|
||||
@@ -560,7 +560,7 @@ def test_typing_overload_import_as():
|
||||
}
|
||||
|
||||
|
||||
def test_typing_overload_from_import_as():
|
||||
def test_typing_overload_from_import_as() -> None:
|
||||
source = (
|
||||
'from typing import overload as bar\n'
|
||||
'\n'
|
||||
@@ -582,7 +582,7 @@ def test_typing_overload_from_import_as():
|
||||
}
|
||||
|
||||
|
||||
def test_typing_overload_not_imported():
|
||||
def test_typing_overload_not_imported() -> None:
|
||||
source = (
|
||||
'@typing.final\n'
|
||||
'def func(x: int, y: int) -> int: pass\n'
|
||||
|
||||
@@ -53,7 +53,7 @@ def teardown_module():
|
||||
enable_colour()
|
||||
|
||||
|
||||
def test_do_prompt():
|
||||
def test_do_prompt() -> None:
|
||||
answers = {
|
||||
'Q2': 'v2',
|
||||
'Q3': 'v3',
|
||||
@@ -61,7 +61,7 @@ def test_do_prompt():
|
||||
'Q5': 'no',
|
||||
'Q6': 'foo',
|
||||
}
|
||||
qs.term_input = mock_input(answers)
|
||||
qs.term_input = mock_input(answers) # type: ignore[assignment]
|
||||
|
||||
assert qs.do_prompt('Q1', default='v1') == 'v1'
|
||||
assert qs.do_prompt('Q3', default='v3_default') == 'v3'
|
||||
@@ -72,14 +72,14 @@ def test_do_prompt():
|
||||
qs.do_prompt('Q6', validator=qs.boolean)
|
||||
|
||||
|
||||
def test_do_prompt_inputstrip():
|
||||
def test_do_prompt_inputstrip() -> None:
|
||||
answers = {
|
||||
'Q1': 'Y',
|
||||
'Q2': ' Yes ',
|
||||
'Q3': 'N',
|
||||
'Q4': 'N ',
|
||||
}
|
||||
qs.term_input = mock_input(answers)
|
||||
qs.term_input = mock_input(answers) # type: ignore[assignment]
|
||||
|
||||
assert qs.do_prompt('Q1') == 'Y'
|
||||
assert qs.do_prompt('Q2') == 'Yes'
|
||||
@@ -87,11 +87,11 @@ def test_do_prompt_inputstrip():
|
||||
assert qs.do_prompt('Q4') == 'N'
|
||||
|
||||
|
||||
def test_do_prompt_with_nonascii():
|
||||
def test_do_prompt_with_nonascii() -> None:
|
||||
answers = {
|
||||
'Q1': '\u30c9\u30a4\u30c4',
|
||||
}
|
||||
qs.term_input = mock_input(answers)
|
||||
qs.term_input = mock_input(answers) # type: ignore[assignment]
|
||||
result = qs.do_prompt('Q1', default='\u65e5\u672c')
|
||||
assert result == '\u30c9\u30a4\u30c4'
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from sphinx.roles import EmphasizedLiteral, _format_rfc_target
|
||||
from sphinx.testing.util import assert_node
|
||||
|
||||
|
||||
def test_samp():
|
||||
def test_samp() -> None:
|
||||
emph_literal_role = EmphasizedLiteral()
|
||||
|
||||
# normal case
|
||||
|
||||
@@ -223,7 +223,7 @@ def test_theme_builds(make_app, rootdir, sphinx_test_tempdir, theme_name):
|
||||
pytest.fail(f'Failed to parse {html_file.relative_to(app.outdir)}: {exc}')
|
||||
|
||||
|
||||
def test_config_file_toml():
|
||||
def test_config_file_toml() -> None:
|
||||
config_path = HERE / 'theme.toml'
|
||||
cfg = _load_theme_toml(config_path)
|
||||
config = _convert_theme_toml(cfg)
|
||||
@@ -237,7 +237,7 @@ def test_config_file_toml():
|
||||
)
|
||||
|
||||
|
||||
def test_config_file_conf():
|
||||
def test_config_file_conf() -> None:
|
||||
config_path = HERE / 'theme.conf'
|
||||
cfg = _load_theme_conf(config_path)
|
||||
config = _convert_theme_conf(cfg)
|
||||
|
||||
@@ -39,7 +39,7 @@ def test_ensuredir(tmp_path):
|
||||
assert path.is_dir()
|
||||
|
||||
|
||||
def test_exported_attributes():
|
||||
def test_exported_attributes() -> None:
|
||||
# RemovedInSphinx90Warning
|
||||
with pytest.warns(
|
||||
RemovedInSphinx90Warning,
|
||||
|
||||
@@ -14,7 +14,7 @@ from sphinx.util.display import (
|
||||
)
|
||||
|
||||
|
||||
def test_display_chunk():
|
||||
def test_display_chunk() -> None:
|
||||
assert display_chunk('hello') == 'hello'
|
||||
assert display_chunk(['hello']) == 'hello'
|
||||
assert display_chunk(['hello', 'sphinx', 'world']) == 'hello .. world'
|
||||
|
||||
@@ -9,7 +9,7 @@ from sphinx.util.docstrings import (
|
||||
)
|
||||
|
||||
|
||||
def test_separate_metadata():
|
||||
def test_separate_metadata() -> None:
|
||||
# metadata only
|
||||
text = ':meta foo: bar\n:meta baz:\n'
|
||||
docstring, metadata = separate_metadata(text)
|
||||
@@ -41,7 +41,7 @@ def test_separate_metadata():
|
||||
assert metadata == {'foo': 'bar'}
|
||||
|
||||
|
||||
def test_prepare_docstring():
|
||||
def test_prepare_docstring() -> None:
|
||||
docstring = """multiline docstring
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
|
||||
@@ -77,7 +77,7 @@ def test_prepare_docstring():
|
||||
assert prepare_docstring(docstring) == ['single line docstring', '']
|
||||
|
||||
|
||||
def test_prepare_commentdoc():
|
||||
def test_prepare_commentdoc() -> None:
|
||||
assert prepare_commentdoc('hello world') == []
|
||||
assert prepare_commentdoc('#: hello world') == ['hello world', '']
|
||||
assert prepare_commentdoc('#: hello world') == [' hello world', '']
|
||||
|
||||
@@ -20,7 +20,7 @@ if TYPE_CHECKING:
|
||||
from sphinx.builders import Builder
|
||||
|
||||
|
||||
def test_register_node():
|
||||
def test_register_node() -> None:
|
||||
class custom_node(nodes.Element):
|
||||
pass
|
||||
|
||||
|
||||
@@ -61,14 +61,14 @@ def make_directive_and_state(
|
||||
return state, directive
|
||||
|
||||
|
||||
def test_sphinx_directive_env():
|
||||
def test_sphinx_directive_env() -> None:
|
||||
state, directive = make_directive_and_state(env=SimpleNamespace())
|
||||
|
||||
assert hasattr(directive, 'env')
|
||||
assert directive.env is state.document.settings.env
|
||||
|
||||
|
||||
def test_sphinx_directive_config():
|
||||
def test_sphinx_directive_config() -> None:
|
||||
env = SimpleNamespace(config=object())
|
||||
state, directive = make_directive_and_state(env=env)
|
||||
|
||||
@@ -77,7 +77,7 @@ def test_sphinx_directive_config():
|
||||
assert directive.config is state.document.settings.env.config
|
||||
|
||||
|
||||
def test_sphinx_directive_get_source_info():
|
||||
def test_sphinx_directive_get_source_info() -> None:
|
||||
env = SimpleNamespace()
|
||||
input_lines = StringList(['spam'], source='<source>')
|
||||
directive = make_directive(env=env, input_lines=input_lines)
|
||||
@@ -85,7 +85,7 @@ def test_sphinx_directive_get_source_info():
|
||||
assert directive.get_source_info() == ('<source>', 1)
|
||||
|
||||
|
||||
def test_sphinx_directive_set_source_info():
|
||||
def test_sphinx_directive_set_source_info() -> None:
|
||||
env = SimpleNamespace()
|
||||
input_lines = StringList(['spam'], source='<source>')
|
||||
directive = make_directive(env=env, input_lines=input_lines)
|
||||
@@ -96,7 +96,7 @@ def test_sphinx_directive_set_source_info():
|
||||
assert node.line == 1
|
||||
|
||||
|
||||
def test_sphinx_directive_get_location():
|
||||
def test_sphinx_directive_get_location() -> None:
|
||||
env = SimpleNamespace()
|
||||
input_lines = StringList(['spam'], source='<source>')
|
||||
directive = make_directive(env=env, input_lines=input_lines)
|
||||
@@ -104,7 +104,7 @@ def test_sphinx_directive_get_location():
|
||||
assert directive.get_location() == '<source>:1'
|
||||
|
||||
|
||||
def test_sphinx_directive_parse_content_to_nodes():
|
||||
def test_sphinx_directive_parse_content_to_nodes() -> None:
|
||||
directive = make_directive(env=SimpleNamespace())
|
||||
content = 'spam\n====\n\nEggs! *Lobster thermidor.*'
|
||||
directive.content = StringList(content.split('\n'), source='<source>')
|
||||
@@ -120,7 +120,7 @@ def test_sphinx_directive_parse_content_to_nodes():
|
||||
assert node.children[1].astext() == 'Eggs! Lobster thermidor.'
|
||||
|
||||
|
||||
def test_sphinx_directive_parse_text_to_nodes():
|
||||
def test_sphinx_directive_parse_text_to_nodes() -> None:
|
||||
directive = make_directive(env=SimpleNamespace())
|
||||
content = 'spam\n====\n\nEggs! *Lobster thermidor.*'
|
||||
|
||||
@@ -135,7 +135,7 @@ def test_sphinx_directive_parse_text_to_nodes():
|
||||
assert node.children[1].astext() == 'Eggs! Lobster thermidor.'
|
||||
|
||||
|
||||
def test_sphinx_directive_parse_inline():
|
||||
def test_sphinx_directive_parse_inline() -> None:
|
||||
directive = make_directive(env=SimpleNamespace())
|
||||
content = 'Eggs! *Lobster thermidor.*'
|
||||
|
||||
|
||||
@@ -144,11 +144,11 @@ def test_copy_asset_overwrite(app):
|
||||
)
|
||||
|
||||
|
||||
def test_template_basename():
|
||||
def test_template_basename() -> None:
|
||||
assert _template_basename(Path('asset.txt')) is None
|
||||
assert _template_basename(Path('asset.txt.jinja')) == Path('asset.txt')
|
||||
assert _template_basename(Path('sidebar.html.jinja')) == Path('sidebar.html')
|
||||
|
||||
|
||||
def test_legacy_template_basename():
|
||||
def test_legacy_template_basename() -> None:
|
||||
assert _template_basename(Path('asset.txt_t')) == Path('asset.txt')
|
||||
|
||||
@@ -16,7 +16,7 @@ from sphinx.errors import SphinxError
|
||||
from sphinx.util import i18n
|
||||
|
||||
|
||||
def test_catalog_info_for_file_and_path():
|
||||
def test_catalog_info_for_file_and_path() -> None:
|
||||
cat = i18n.CatalogInfo('path', 'domain', 'utf-8')
|
||||
assert cat.po_file == 'domain.po'
|
||||
assert cat.mo_file == 'domain.mo'
|
||||
@@ -24,7 +24,7 @@ def test_catalog_info_for_file_and_path():
|
||||
assert cat.mo_path == Path('path', 'domain.mo')
|
||||
|
||||
|
||||
def test_catalog_info_for_sub_domain_file_and_path():
|
||||
def test_catalog_info_for_sub_domain_file_and_path() -> None:
|
||||
cat = i18n.CatalogInfo('path', 'sub/domain', 'utf-8')
|
||||
assert cat.po_file == 'sub/domain.po'
|
||||
assert cat.mo_file == 'sub/domain.mo'
|
||||
@@ -102,7 +102,7 @@ def test_format_date():
|
||||
assert i18n.format_date(format, date=datet, language='en') == '+0000'
|
||||
|
||||
|
||||
def test_format_date_timezone():
|
||||
def test_format_date_timezone() -> None:
|
||||
dt = datetime.datetime(2016, 8, 7, 5, 11, 17, 0, tzinfo=datetime.UTC)
|
||||
if time.localtime(dt.timestamp()).tm_gmtoff == 0:
|
||||
raise pytest.skip('Local time zone is GMT') # NoQA: EM101,TRY003
|
||||
|
||||
@@ -25,7 +25,7 @@ def test_get_image_size(rootdir):
|
||||
|
||||
|
||||
@pytest.mark.filterwarnings('ignore:The content argument')
|
||||
def test_guess_mimetype():
|
||||
def test_guess_mimetype() -> None:
|
||||
# guess by filename
|
||||
assert guess_mimetype('img.png') == 'image/png'
|
||||
assert guess_mimetype('img.jpg') == 'image/jpeg'
|
||||
@@ -39,14 +39,14 @@ def test_guess_mimetype():
|
||||
assert guess_mimetype('no_extension', 'text/plain') == 'text/plain'
|
||||
|
||||
|
||||
def test_get_image_extension():
|
||||
def test_get_image_extension() -> None:
|
||||
assert get_image_extension('image/png') == '.png'
|
||||
assert get_image_extension('image/jpeg') == '.jpg'
|
||||
assert get_image_extension('image/svg+xml') == '.svg'
|
||||
assert get_image_extension('text/plain') is None
|
||||
|
||||
|
||||
def test_parse_data_uri():
|
||||
def test_parse_data_uri() -> None:
|
||||
# standard case
|
||||
uri = (
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4'
|
||||
|
||||
@@ -8,7 +8,7 @@ from sphinx.errors import ExtensionError
|
||||
from sphinx.util._importer import import_object
|
||||
|
||||
|
||||
def test_import_object():
|
||||
def test_import_object() -> None:
|
||||
module = import_object('sphinx')
|
||||
assert module.__name__ == 'sphinx'
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ def test_TypeAliasForwardRef():
|
||||
assert sig_str == "TypeAliasForwardRef('example') | None"
|
||||
|
||||
|
||||
def test_TypeAliasNamespace():
|
||||
def test_TypeAliasNamespace() -> None:
|
||||
import logging.config
|
||||
|
||||
type_alias = TypeAliasNamespace({
|
||||
@@ -138,13 +138,13 @@ def test_TypeAliasNamespace():
|
||||
assert type_alias['unknown']
|
||||
|
||||
|
||||
def test_signature():
|
||||
def test_signature() -> None:
|
||||
# literals
|
||||
with pytest.raises(TypeError):
|
||||
inspect.signature(1)
|
||||
inspect.signature(1) # type: ignore[arg-type]
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
inspect.signature('')
|
||||
inspect.signature('') # type: ignore[arg-type]
|
||||
|
||||
# builtins are supported on a case-by-case basis, depending on whether
|
||||
# they define __text_signature__
|
||||
@@ -165,7 +165,7 @@ def test_signature():
|
||||
assert sig == '(a, b, c=1, d=2, *e, **f)'
|
||||
|
||||
|
||||
def test_signature_partial():
|
||||
def test_signature_partial() -> None:
|
||||
def fun(a, b, c=1, d=2):
|
||||
pass
|
||||
|
||||
@@ -175,7 +175,7 @@ def test_signature_partial():
|
||||
assert stringify_signature(sig) == '(b, *, c=11, d=2)'
|
||||
|
||||
|
||||
def test_signature_methods():
|
||||
def test_signature_methods() -> None:
|
||||
class Foo:
|
||||
def meth1(self, arg1, **kwargs):
|
||||
pass
|
||||
@@ -222,7 +222,7 @@ def test_signature_methods():
|
||||
assert stringify_signature(sig) == '(arg1, **kwargs)'
|
||||
|
||||
|
||||
def test_signature_partialmethod():
|
||||
def test_signature_partialmethod() -> None:
|
||||
from functools import partialmethod
|
||||
|
||||
class Foo:
|
||||
@@ -247,7 +247,7 @@ def test_signature_partialmethod():
|
||||
assert stringify_signature(sig) == '()'
|
||||
|
||||
|
||||
def test_signature_annotations():
|
||||
def test_signature_annotations() -> None:
|
||||
import tests.test_util.typing_test_data as mod
|
||||
|
||||
# Class annotations
|
||||
@@ -396,7 +396,7 @@ def test_signature_annotations():
|
||||
)
|
||||
|
||||
|
||||
def test_signature_from_str_basic():
|
||||
def test_signature_from_str_basic() -> None:
|
||||
signature = '(a, b, *args, c=0, d="blah", **kwargs)'
|
||||
sig = inspect.signature_from_str(signature)
|
||||
assert list(sig.parameters.keys()) == ['a', 'b', 'args', 'c', 'd', 'kwargs']
|
||||
@@ -427,7 +427,7 @@ def test_signature_from_str_basic():
|
||||
assert sig.return_annotation == Parameter.empty
|
||||
|
||||
|
||||
def test_signature_from_str_default_values():
|
||||
def test_signature_from_str_default_values() -> None:
|
||||
signature = (
|
||||
'(a=0, b=0.0, c="str", d=b"bytes", e=..., f=True, '
|
||||
'g=[1, 2, 3], h={"a": 1}, i={1, 2, 3}, '
|
||||
@@ -449,7 +449,7 @@ def test_signature_from_str_default_values():
|
||||
assert sig.parameters['m'].default == 'foo.bar.CONSTANT'
|
||||
|
||||
|
||||
def test_signature_from_str_annotations():
|
||||
def test_signature_from_str_annotations() -> None:
|
||||
signature = '(a: int, *args: bytes, b: str = "blah", **kwargs: float) -> None'
|
||||
sig = inspect.signature_from_str(signature)
|
||||
assert list(sig.parameters.keys()) == ['a', 'args', 'b', 'kwargs']
|
||||
@@ -460,7 +460,7 @@ def test_signature_from_str_annotations():
|
||||
assert sig.return_annotation == 'None'
|
||||
|
||||
|
||||
def test_signature_from_str_complex_annotations():
|
||||
def test_signature_from_str_complex_annotations() -> None:
|
||||
sig = inspect.signature_from_str('() -> Tuple[str, int, ...]')
|
||||
assert sig.return_annotation == 'Tuple[str, int, ...]'
|
||||
|
||||
@@ -468,7 +468,7 @@ def test_signature_from_str_complex_annotations():
|
||||
assert sig.return_annotation == 'Callable[[int, int], int]'
|
||||
|
||||
|
||||
def test_signature_from_str_kwonly_args():
|
||||
def test_signature_from_str_kwonly_args() -> None:
|
||||
sig = inspect.signature_from_str('(a, *, b)')
|
||||
assert list(sig.parameters.keys()) == ['a', 'b']
|
||||
assert sig.parameters['a'].kind == Parameter.POSITIONAL_OR_KEYWORD
|
||||
@@ -477,7 +477,7 @@ def test_signature_from_str_kwonly_args():
|
||||
assert sig.parameters['b'].default == Parameter.empty
|
||||
|
||||
|
||||
def test_signature_from_str_positionaly_only_args():
|
||||
def test_signature_from_str_positionaly_only_args() -> None:
|
||||
sig = inspect.signature_from_str('(a, b=0, /, c=1)')
|
||||
assert list(sig.parameters.keys()) == ['a', 'b', 'c']
|
||||
assert sig.parameters['a'].kind == Parameter.POSITIONAL_ONLY
|
||||
@@ -488,7 +488,7 @@ def test_signature_from_str_positionaly_only_args():
|
||||
assert sig.parameters['c'].default == '1'
|
||||
|
||||
|
||||
def test_signature_from_str_invalid():
|
||||
def test_signature_from_str_invalid() -> None:
|
||||
with pytest.raises(SyntaxError):
|
||||
inspect.signature_from_str('')
|
||||
|
||||
@@ -525,7 +525,7 @@ def test_signature_from_ast():
|
||||
assert sig.return_annotation == Parameter.empty
|
||||
|
||||
|
||||
def test_safe_getattr_with_default():
|
||||
def test_safe_getattr_with_default() -> None:
|
||||
class Foo:
|
||||
def __getattr__(self, item):
|
||||
raise Exception
|
||||
@@ -537,7 +537,7 @@ def test_safe_getattr_with_default():
|
||||
assert result == 'baz'
|
||||
|
||||
|
||||
def test_safe_getattr_with_exception():
|
||||
def test_safe_getattr_with_exception() -> None:
|
||||
class Foo:
|
||||
def __getattr__(self, item):
|
||||
raise Exception
|
||||
@@ -548,7 +548,7 @@ def test_safe_getattr_with_exception():
|
||||
inspect.safe_getattr(obj, 'bar')
|
||||
|
||||
|
||||
def test_safe_getattr_with_property_exception():
|
||||
def test_safe_getattr_with_property_exception() -> None:
|
||||
class Foo:
|
||||
@property
|
||||
def bar(self):
|
||||
@@ -560,7 +560,7 @@ def test_safe_getattr_with_property_exception():
|
||||
inspect.safe_getattr(obj, 'bar')
|
||||
|
||||
|
||||
def test_safe_getattr_with___dict___override():
|
||||
def test_safe_getattr_with___dict___override() -> None:
|
||||
class Foo:
|
||||
@property
|
||||
def __dict__(self):
|
||||
@@ -572,19 +572,19 @@ def test_safe_getattr_with___dict___override():
|
||||
inspect.safe_getattr(obj, 'bar')
|
||||
|
||||
|
||||
def test_dictionary_sorting():
|
||||
def test_dictionary_sorting() -> None:
|
||||
dictionary = {'c': 3, 'a': 1, 'd': 2, 'b': 4}
|
||||
description = inspect.object_description(dictionary)
|
||||
assert description == "{'a': 1, 'b': 4, 'c': 3, 'd': 2}"
|
||||
|
||||
|
||||
def test_set_sorting():
|
||||
def test_set_sorting() -> None:
|
||||
set_ = set('gfedcba')
|
||||
description = inspect.object_description(set_)
|
||||
assert description == "{'a', 'b', 'c', 'd', 'e', 'f', 'g'}"
|
||||
|
||||
|
||||
def test_set_sorting_enum():
|
||||
def test_set_sorting_enum() -> None:
|
||||
class MyEnum(enum.Enum):
|
||||
a = 1
|
||||
b = 2
|
||||
@@ -595,13 +595,13 @@ def test_set_sorting_enum():
|
||||
assert description == '{MyEnum.a, MyEnum.b, MyEnum.c}'
|
||||
|
||||
|
||||
def test_set_sorting_fallback():
|
||||
def test_set_sorting_fallback() -> None:
|
||||
set_ = {None, 1}
|
||||
description = inspect.object_description(set_)
|
||||
assert description == '{1, None}'
|
||||
|
||||
|
||||
def test_deterministic_nested_collection_descriptions():
|
||||
def test_deterministic_nested_collection_descriptions() -> None:
|
||||
# sortable
|
||||
assert inspect.object_description([{1, 2, 3, 10}]) == '[{1, 2, 3, 10}]'
|
||||
assert inspect.object_description(({1, 2, 3, 10},)) == '({1, 2, 3, 10},)'
|
||||
@@ -612,13 +612,13 @@ def test_deterministic_nested_collection_descriptions():
|
||||
assert inspect.object_description(({None, 1, 'A'},)) == "({'A', 1, None},)"
|
||||
|
||||
|
||||
def test_frozenset_sorting():
|
||||
def test_frozenset_sorting() -> None:
|
||||
frozenset_ = frozenset('gfedcba')
|
||||
description = inspect.object_description(frozenset_)
|
||||
assert description == "frozenset({'a', 'b', 'c', 'd', 'e', 'f', 'g'})"
|
||||
|
||||
|
||||
def test_frozenset_sorting_fallback():
|
||||
def test_frozenset_sorting_fallback() -> None:
|
||||
frozenset_ = frozenset((None, 1))
|
||||
description = inspect.object_description(frozenset_)
|
||||
assert description == 'frozenset({1, None})'
|
||||
@@ -656,7 +656,7 @@ def test_recursive_collection_description():
|
||||
assert description_d == '[5, 6, 7, 8, [1, 2, 3, 4, list(...)]]'
|
||||
|
||||
|
||||
def test_dict_customtype():
|
||||
def test_dict_customtype() -> None:
|
||||
class CustomType:
|
||||
def __init__(self, value):
|
||||
self._value = value
|
||||
@@ -670,7 +670,7 @@ def test_dict_customtype():
|
||||
assert '<CustomType(2)>: 2' in description
|
||||
|
||||
|
||||
def test_object_description_enum():
|
||||
def test_object_description_enum() -> None:
|
||||
class MyEnum(enum.Enum):
|
||||
FOO = 1
|
||||
BAR = 2
|
||||
@@ -678,7 +678,7 @@ def test_object_description_enum():
|
||||
assert inspect.object_description(MyEnum.FOO) == 'MyEnum.FOO'
|
||||
|
||||
|
||||
def test_object_description_enum_custom_repr():
|
||||
def test_object_description_enum_custom_repr() -> None:
|
||||
class MyEnum(enum.Enum):
|
||||
FOO = 1
|
||||
BAR = 2
|
||||
@@ -689,7 +689,7 @@ def test_object_description_enum_custom_repr():
|
||||
assert inspect.object_description(MyEnum.FOO) == 'FOO'
|
||||
|
||||
|
||||
def test_getslots():
|
||||
def test_getslots() -> None:
|
||||
class Foo:
|
||||
pass
|
||||
|
||||
@@ -804,14 +804,14 @@ def test_is_classmethod_like(expect, klass, name):
|
||||
assert inspect.is_classmethod_like(subject) is expect
|
||||
|
||||
|
||||
def test_isstaticmethod():
|
||||
def test_isstaticmethod() -> None:
|
||||
assert inspect.isstaticmethod(Base.staticmeth, Base, 'staticmeth')
|
||||
assert not inspect.isstaticmethod(Base.meth, Base, 'meth')
|
||||
assert inspect.isstaticmethod(Inherited.staticmeth, Inherited, 'staticmeth')
|
||||
assert not inspect.isstaticmethod(Inherited.meth, Inherited, 'meth')
|
||||
|
||||
|
||||
def test_iscoroutinefunction():
|
||||
def test_iscoroutinefunction() -> None:
|
||||
# function
|
||||
assert not inspect.iscoroutinefunction(func)
|
||||
# coroutine
|
||||
@@ -830,12 +830,12 @@ def test_iscoroutinefunction():
|
||||
assert inspect.iscoroutinefunction(partial_coroutinemeth)
|
||||
|
||||
|
||||
def test_iscoroutinefunction_wrapped():
|
||||
def test_iscoroutinefunction_wrapped() -> None:
|
||||
# function wrapping a callable obj
|
||||
assert inspect.isfunction(_decorator(coroutinefunc))
|
||||
|
||||
|
||||
def test_isfunction():
|
||||
def test_isfunction() -> None:
|
||||
# fmt: off
|
||||
assert inspect.isfunction(func) # function
|
||||
assert inspect.isfunction(partial_func) # partial-ed function
|
||||
@@ -847,12 +847,12 @@ def test_isfunction():
|
||||
# fmt: on
|
||||
|
||||
|
||||
def test_isfunction_wrapped():
|
||||
def test_isfunction_wrapped() -> None:
|
||||
# function wrapping a callable obj
|
||||
assert inspect.isfunction(_decorator(_Callable()))
|
||||
|
||||
|
||||
def test_isbuiltin():
|
||||
def test_isbuiltin() -> None:
|
||||
# fmt: off
|
||||
assert inspect.isbuiltin(builtin_func) # builtin function
|
||||
assert inspect.isbuiltin(partial_builtin_func) # partial-ed builtin function
|
||||
@@ -863,7 +863,7 @@ def test_isbuiltin():
|
||||
# fmt: on
|
||||
|
||||
|
||||
def test_isdescriptor():
|
||||
def test_isdescriptor() -> None:
|
||||
# fmt: off
|
||||
assert inspect.isdescriptor(Base.prop) # property of class
|
||||
assert not inspect.isdescriptor(Base().prop) # property of instance
|
||||
@@ -873,7 +873,7 @@ def test_isdescriptor():
|
||||
# fmt: on
|
||||
|
||||
|
||||
def test_isattributedescriptor():
|
||||
def test_isattributedescriptor() -> None:
|
||||
# fmt: off
|
||||
assert inspect.isattributedescriptor(Base.prop) # property
|
||||
assert not inspect.isattributedescriptor(Base.meth) # method
|
||||
@@ -899,7 +899,7 @@ def test_isattributedescriptor():
|
||||
pass
|
||||
|
||||
|
||||
def test_isproperty():
|
||||
def test_isproperty() -> None:
|
||||
# fmt: off
|
||||
assert inspect.isproperty(Base.prop) # property of class
|
||||
assert not inspect.isproperty(Base().prop) # property of instance
|
||||
@@ -909,7 +909,7 @@ def test_isproperty():
|
||||
# fmt: on
|
||||
|
||||
|
||||
def test_isgenericalias():
|
||||
def test_isgenericalias() -> None:
|
||||
#: A list of int
|
||||
T = List[int] # NoQA: UP006
|
||||
S = list[Union[str, None]] # NoQA: UP007
|
||||
@@ -927,7 +927,7 @@ def test_isgenericalias():
|
||||
assert not inspect.isgenericalias(Base)
|
||||
|
||||
|
||||
def test_unpartial():
|
||||
def test_unpartial() -> None:
|
||||
def func1(a, b, c):
|
||||
pass
|
||||
|
||||
@@ -974,7 +974,7 @@ def test_getdoc_inherited_decorated_method():
|
||||
assert inspect.getdoc(Bar.meth, getattr, True, Bar, 'meth') == Foo.meth.__doc__
|
||||
|
||||
|
||||
def test_is_builtin_class_method():
|
||||
def test_is_builtin_class_method() -> None:
|
||||
class MyInt(int):
|
||||
def my_method(self):
|
||||
pass
|
||||
|
||||
@@ -21,7 +21,7 @@ if TYPE_CHECKING:
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_read_inventory_v1():
|
||||
def test_read_inventory_v1() -> None:
|
||||
inv = InventoryFile.loads(INVENTORY_V1, uri='/util')
|
||||
assert inv['py:module', 'module'] == _InventoryItem(
|
||||
project_name='foo',
|
||||
@@ -37,7 +37,7 @@ def test_read_inventory_v1():
|
||||
)
|
||||
|
||||
|
||||
def test_read_inventory_v2():
|
||||
def test_read_inventory_v2() -> None:
|
||||
inv = InventoryFile.loads(INVENTORY_V2, uri='/util')
|
||||
|
||||
assert len(inv.data['py:module']) == 2
|
||||
@@ -61,7 +61,7 @@ def test_read_inventory_v2():
|
||||
)
|
||||
|
||||
|
||||
def test_read_inventory_v2_not_having_version():
|
||||
def test_read_inventory_v2_not_having_version() -> None:
|
||||
inv = InventoryFile.loads(INVENTORY_V2_NO_VERSION, uri='/util')
|
||||
assert inv['py:module', 'module1'] == _InventoryItem(
|
||||
project_name='foo',
|
||||
|
||||
@@ -5,7 +5,7 @@ import pytest
|
||||
from sphinx.util._lines import parse_line_num_spec
|
||||
|
||||
|
||||
def test_parse_line_num_spec():
|
||||
def test_parse_line_num_spec() -> None:
|
||||
assert parse_line_num_spec('1,2,3', 10) == [0, 1, 2]
|
||||
assert parse_line_num_spec('4, 5, 6', 10) == [3, 4, 5]
|
||||
assert parse_line_num_spec('-4', 10) == [0, 1, 2, 3]
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
from sphinx.util.matching import Matcher, compile_matchers, get_matching_files
|
||||
|
||||
|
||||
def test_compile_matchers():
|
||||
def test_compile_matchers() -> None:
|
||||
# exact matching
|
||||
pat = compile_matchers(['hello.py']).pop()
|
||||
assert pat('hello.py')
|
||||
@@ -77,7 +77,7 @@ def test_compile_matchers():
|
||||
assert not pat('hello.py')
|
||||
|
||||
|
||||
def test_Matcher():
|
||||
def test_Matcher() -> None:
|
||||
matcher = Matcher(['hello.py', '**/world.py'])
|
||||
assert matcher('hello.py')
|
||||
assert not matcher('subdir/hello.py')
|
||||
|
||||
@@ -160,7 +160,7 @@ def test_extract_messages(rst, node_cls, count):
|
||||
assert_node_count(msg, node_cls, count)
|
||||
|
||||
|
||||
def test_extract_messages_without_rawsource():
|
||||
def test_extract_messages_without_rawsource() -> None:
|
||||
"""Check node.rawsource is fall-backed by using node.astext() value.
|
||||
|
||||
`extract_message` which is used from Sphinx i18n feature drop ``not node.rawsource``
|
||||
@@ -251,7 +251,7 @@ def test_split_explicit_target(title, expected):
|
||||
assert split_explicit_title(title) == expected
|
||||
|
||||
|
||||
def test_apply_source_workaround_literal_block_no_source():
|
||||
def test_apply_source_workaround_literal_block_no_source() -> None:
|
||||
"""Regression test for https://github.com/sphinx-doc/sphinx/issues/11091.
|
||||
|
||||
Test that apply_source_workaround doesn't raise.
|
||||
|
||||
@@ -8,14 +8,14 @@ from jinja2 import Environment
|
||||
from sphinx.util.rst import append_epilog, escape, heading, prepend_prolog, textwidth
|
||||
|
||||
|
||||
def test_escape():
|
||||
def test_escape() -> None:
|
||||
assert escape(':ref:`id`') == r'\:ref\:\`id\`'
|
||||
assert escape('footnote [#]_') == r'footnote \[\#\]\_'
|
||||
assert escape('sphinx.application') == r'sphinx.application'
|
||||
assert escape('.. toctree::') == r'\.. toctree\:\:'
|
||||
|
||||
|
||||
def test_append_epilog():
|
||||
def test_append_epilog() -> None:
|
||||
epilog = 'this is rst_epilog\ngood-bye reST!'
|
||||
content = StringList(
|
||||
['hello Sphinx world', 'Sphinx is a document generator'],
|
||||
@@ -32,7 +32,7 @@ def test_append_epilog():
|
||||
]
|
||||
|
||||
|
||||
def test_prepend_prolog():
|
||||
def test_prepend_prolog() -> None:
|
||||
prolog = 'this is rst_prolog\nhello reST!'
|
||||
content = StringList(
|
||||
[
|
||||
@@ -59,7 +59,7 @@ def test_prepend_prolog():
|
||||
]
|
||||
|
||||
|
||||
def test_prepend_prolog_with_CR():
|
||||
def test_prepend_prolog_with_CR() -> None:
|
||||
# prolog having CR at tail
|
||||
prolog = 'this is rst_prolog\nhello reST!\n'
|
||||
content = StringList(
|
||||
@@ -77,7 +77,7 @@ def test_prepend_prolog_with_CR():
|
||||
]
|
||||
|
||||
|
||||
def test_prepend_prolog_without_CR():
|
||||
def test_prepend_prolog_without_CR() -> None:
|
||||
# prolog not having CR at tail
|
||||
prolog = 'this is rst_prolog\nhello reST!'
|
||||
content = StringList(
|
||||
@@ -95,7 +95,7 @@ def test_prepend_prolog_without_CR():
|
||||
]
|
||||
|
||||
|
||||
def test_prepend_prolog_with_roles_in_sections():
|
||||
def test_prepend_prolog_with_roles_in_sections() -> None:
|
||||
prolog = 'this is rst_prolog\nhello reST!'
|
||||
content = StringList(
|
||||
[
|
||||
@@ -126,7 +126,7 @@ def test_prepend_prolog_with_roles_in_sections():
|
||||
]
|
||||
|
||||
|
||||
def test_prepend_prolog_with_roles_in_sections_with_newline():
|
||||
def test_prepend_prolog_with_roles_in_sections_with_newline() -> None:
|
||||
# prologue with trailing line break
|
||||
prolog = 'this is rst_prolog\nhello reST!\n'
|
||||
content = StringList([':mod:`foo`', '-' * 10, '', 'hello'], 'dummy.rst')
|
||||
@@ -143,7 +143,7 @@ def test_prepend_prolog_with_roles_in_sections_with_newline():
|
||||
]
|
||||
|
||||
|
||||
def test_prepend_prolog_with_roles_in_sections_without_newline():
|
||||
def test_prepend_prolog_with_roles_in_sections_without_newline() -> None:
|
||||
# prologue with no trailing line break
|
||||
prolog = 'this is rst_prolog\nhello reST!'
|
||||
content = StringList([':mod:`foo`', '-' * 10, '', 'hello'], 'dummy.rst')
|
||||
@@ -160,13 +160,13 @@ def test_prepend_prolog_with_roles_in_sections_without_newline():
|
||||
]
|
||||
|
||||
|
||||
def test_textwidth():
|
||||
def test_textwidth() -> None:
|
||||
assert textwidth('Hello') == 5
|
||||
assert textwidth('русский язык') == 12
|
||||
assert textwidth('русский язык', 'WFA') == 23 # Cyrillic are ambiguous chars
|
||||
|
||||
|
||||
def test_heading():
|
||||
def test_heading() -> None:
|
||||
env = Environment(autoescape=True)
|
||||
env.extend(language=None)
|
||||
|
||||
@@ -177,5 +177,5 @@ def test_heading():
|
||||
assert heading(env, 'русский язык', 1) == 'русский язык\n============'
|
||||
|
||||
# language=ja: ambiguous
|
||||
env.language = 'ja'
|
||||
env.language = 'ja' # type: ignore[attr-defined]
|
||||
assert heading(env, 'русский язык', 1) == 'русский язык\n======================='
|
||||
|
||||
@@ -5,13 +5,13 @@ from __future__ import annotations
|
||||
from sphinx.util.template import ReSTRenderer
|
||||
|
||||
|
||||
def test_ReSTRenderer_escape():
|
||||
def test_ReSTRenderer_escape() -> None:
|
||||
r = ReSTRenderer()
|
||||
template = '{{ "*hello*" | e }}'
|
||||
assert r.render_string(template, {}) == r'\*hello\*'
|
||||
|
||||
|
||||
def test_ReSTRenderer_heading():
|
||||
def test_ReSTRenderer_heading() -> None:
|
||||
r = ReSTRenderer()
|
||||
|
||||
template = '{{ "hello" | heading }}'
|
||||
@@ -24,6 +24,6 @@ def test_ReSTRenderer_heading():
|
||||
assert r.render_string(template, {}) == 'русский язык\n------------'
|
||||
|
||||
# language: ja
|
||||
r.env.language = 'ja'
|
||||
r.env.language = 'ja' # type: ignore[attr-defined]
|
||||
template = '{{ "русский язык" | heading }}'
|
||||
assert r.render_string(template, {}) == 'русский язык\n======================='
|
||||
|
||||
@@ -108,7 +108,7 @@ class Gt:
|
||||
gt: float
|
||||
|
||||
|
||||
def test_restify():
|
||||
def test_restify() -> None:
|
||||
assert restify(int) == ':py:class:`int`'
|
||||
assert restify(int, 'smart') == ':py:class:`int`'
|
||||
|
||||
@@ -137,7 +137,7 @@ def test_restify():
|
||||
assert restify('str', 'smart') == 'str'
|
||||
|
||||
|
||||
def test_is_invalid_builtin_class():
|
||||
def test_is_invalid_builtin_class() -> None:
|
||||
# if these tests start failing, it means that the __module__
|
||||
# of one of these classes has changed, and _INVALID_BUILTIN_CLASSES
|
||||
# in sphinx.util.typing needs to be updated.
|
||||
@@ -280,7 +280,7 @@ def test_restify_type_hints_containers():
|
||||
)
|
||||
|
||||
|
||||
def test_restify_Annotated():
|
||||
def test_restify_Annotated() -> None:
|
||||
ann_rst = restify(Annotated[str, 'foo', 'bar'])
|
||||
assert ann_rst == (
|
||||
":py:class:`~typing.Annotated`\\ [:py:class:`str`, 'foo', 'bar']"
|
||||
@@ -299,7 +299,7 @@ def test_restify_Annotated():
|
||||
)
|
||||
|
||||
|
||||
def test_restify_type_hints_Callable():
|
||||
def test_restify_type_hints_Callable() -> None:
|
||||
assert restify(t.Callable) == ':py:class:`~typing.Callable`'
|
||||
assert restify(t.Callable[[str], int]) == (
|
||||
':py:class:`~typing.Callable`\\ [[:py:class:`str`], :py:class:`int`]'
|
||||
@@ -316,7 +316,7 @@ def test_restify_type_hints_Callable():
|
||||
)
|
||||
|
||||
|
||||
def test_restify_type_hints_Union():
|
||||
def test_restify_type_hints_Union() -> None:
|
||||
assert restify(Union[int]) == ':py:class:`int`'
|
||||
assert restify(Union[int, str]) == ':py:class:`int` | :py:class:`str`'
|
||||
assert restify(Optional[int]) == ':py:class:`int` | :py:obj:`None`'
|
||||
@@ -399,7 +399,7 @@ def test_restify_type_hints_typevars():
|
||||
assert ann_rst == ':py:class:`~tests.test_util.test_util_typing.MyInt`'
|
||||
|
||||
|
||||
def test_restify_type_hints_custom_class():
|
||||
def test_restify_type_hints_custom_class() -> None:
|
||||
assert restify(MyClass1) == ':py:class:`tests.test_util.test_util_typing.MyClass1`'
|
||||
ann_rst = restify(MyClass1, 'smart')
|
||||
assert ann_rst == ':py:class:`~tests.test_util.test_util_typing.MyClass1`'
|
||||
@@ -410,7 +410,7 @@ def test_restify_type_hints_custom_class():
|
||||
assert ann_rst == ':py:class:`~tests.test_util.test_util_typing.<MyClass2>`'
|
||||
|
||||
|
||||
def test_restify_type_hints_alias():
|
||||
def test_restify_type_hints_alias() -> None:
|
||||
MyStr = str
|
||||
MyTypingTuple = Tuple[str, str]
|
||||
MyTuple = tuple[str, str]
|
||||
@@ -433,7 +433,7 @@ def test_restify_type_ForwardRef():
|
||||
)
|
||||
|
||||
|
||||
def test_restify_type_Literal():
|
||||
def test_restify_type_Literal() -> None:
|
||||
ann_rst = restify(Literal[1, '2', '\r'])
|
||||
assert ann_rst == ":py:obj:`~typing.Literal`\\ [1, '2', '\\r']"
|
||||
|
||||
@@ -447,7 +447,7 @@ def test_restify_type_Literal():
|
||||
)
|
||||
|
||||
|
||||
def test_restify_pep_585():
|
||||
def test_restify_pep_585() -> None:
|
||||
assert restify(list[str]) == ':py:class:`list`\\ [:py:class:`str`]'
|
||||
ann_rst = restify(dict[str, str])
|
||||
assert ann_rst == ':py:class:`dict`\\ [:py:class:`str`, :py:class:`str`]'
|
||||
@@ -479,7 +479,7 @@ def test_restify_pep_585():
|
||||
)
|
||||
|
||||
|
||||
def test_restify_Unpack():
|
||||
def test_restify_Unpack() -> None:
|
||||
from typing_extensions import Unpack as UnpackCompat
|
||||
|
||||
class X(t.TypedDict):
|
||||
@@ -502,7 +502,7 @@ def test_restify_Unpack():
|
||||
assert restify(t.Unpack['X'], 'smart') == expect
|
||||
|
||||
|
||||
def test_restify_type_union_operator():
|
||||
def test_restify_type_union_operator() -> None:
|
||||
assert restify(int | None) == ':py:class:`int` | :py:obj:`None`'
|
||||
assert restify(None | int) == ':py:obj:`None` | :py:class:`int`'
|
||||
assert restify(int | str) == ':py:class:`int` | :py:class:`str`'
|
||||
@@ -510,14 +510,14 @@ def test_restify_type_union_operator():
|
||||
assert ann_rst == ':py:class:`int` | :py:class:`str` | :py:obj:`None`'
|
||||
|
||||
|
||||
def test_restify_broken_type_hints():
|
||||
def test_restify_broken_type_hints() -> None:
|
||||
ann_rst = restify(BrokenType)
|
||||
assert ann_rst == ':py:class:`tests.test_util.test_util_typing.BrokenType`'
|
||||
ann_rst = restify(BrokenType, 'smart')
|
||||
assert ann_rst == ':py:class:`~tests.test_util.test_util_typing.BrokenType`'
|
||||
|
||||
|
||||
def test_restify_mock():
|
||||
def test_restify_mock() -> None:
|
||||
with mock(['unknown']):
|
||||
import unknown # type: ignore[import-not-found]
|
||||
|
||||
@@ -540,7 +540,7 @@ def test_restify_type_hints_paramspec():
|
||||
assert restify(P.kwargs, 'smart') == 'P.kwargs'
|
||||
|
||||
|
||||
def test_stringify_annotation():
|
||||
def test_stringify_annotation() -> None:
|
||||
assert stringify_annotation(int, 'fully-qualified-except-typing') == 'int'
|
||||
assert stringify_annotation(int, 'smart') == 'int'
|
||||
|
||||
@@ -726,7 +726,7 @@ def test_stringify_type_hints_pep_585():
|
||||
assert ann_str == 'tuple[~typing.List[dict[int, str]], str, ...]'
|
||||
|
||||
|
||||
def test_stringify_Annotated():
|
||||
def test_stringify_Annotated() -> None:
|
||||
ann_str = stringify_annotation(
|
||||
Annotated[str, 'foo', 'bar'], 'fully-qualified-except-typing'
|
||||
)
|
||||
@@ -745,7 +745,7 @@ def test_stringify_Annotated():
|
||||
)
|
||||
|
||||
|
||||
def test_stringify_Unpack():
|
||||
def test_stringify_Unpack() -> None:
|
||||
class X(t.TypedDict):
|
||||
x: int
|
||||
y: int
|
||||
@@ -755,7 +755,7 @@ def test_stringify_Unpack():
|
||||
assert stringify_annotation(t.Unpack['X'], 'smart') == '~typing.Unpack[X]'
|
||||
|
||||
|
||||
def test_stringify_type_hints_string():
|
||||
def test_stringify_type_hints_string() -> None:
|
||||
assert stringify_annotation('int', 'fully-qualified-except-typing') == 'int'
|
||||
assert stringify_annotation('int', 'fully-qualified') == 'int'
|
||||
assert stringify_annotation('int', 'smart') == 'int'
|
||||
@@ -789,7 +789,7 @@ def test_stringify_type_hints_string():
|
||||
assert stringify_annotation('unknown', 'smart') == 'unknown'
|
||||
|
||||
|
||||
def test_stringify_type_hints_Callable():
|
||||
def test_stringify_type_hints_Callable() -> None:
|
||||
ann_str = stringify_annotation(t.Callable, 'fully-qualified-except-typing')
|
||||
assert ann_str == 'Callable'
|
||||
assert stringify_annotation(t.Callable, 'fully-qualified') == 'typing.Callable'
|
||||
@@ -838,7 +838,7 @@ def test_stringify_type_hints_Callable():
|
||||
assert ann_str == '~collections.abc.Callable[[...], int]'
|
||||
|
||||
|
||||
def test_stringify_type_hints_Union():
|
||||
def test_stringify_type_hints_Union() -> None:
|
||||
ann_str = stringify_annotation(Optional[int], 'fully-qualified-except-typing')
|
||||
assert ann_str == 'int | None'
|
||||
assert stringify_annotation(Optional[int], 'fully-qualified') == 'int | None'
|
||||
@@ -918,7 +918,7 @@ def test_stringify_type_hints_typevars():
|
||||
assert ann_str == '~tests.test_util.test_util_typing.MyInt'
|
||||
|
||||
|
||||
def test_stringify_type_hints_custom_class():
|
||||
def test_stringify_type_hints_custom_class() -> None:
|
||||
ann_str = stringify_annotation(MyClass1, 'fully-qualified-except-typing')
|
||||
assert ann_str == 'tests.test_util.test_util_typing.MyClass1'
|
||||
ann_str = stringify_annotation(MyClass1, 'smart')
|
||||
@@ -930,7 +930,7 @@ def test_stringify_type_hints_custom_class():
|
||||
assert ann_str == '~tests.test_util.test_util_typing.<MyClass2>'
|
||||
|
||||
|
||||
def test_stringify_type_hints_alias():
|
||||
def test_stringify_type_hints_alias() -> None:
|
||||
MyStr = str
|
||||
MyTuple = Tuple[str, str]
|
||||
|
||||
@@ -941,7 +941,7 @@ def test_stringify_type_hints_alias():
|
||||
assert stringify_annotation(MyTuple, 'smart') == '~typing.Tuple[str, str]'
|
||||
|
||||
|
||||
def test_stringify_type_Literal():
|
||||
def test_stringify_type_Literal() -> None:
|
||||
ann_str = stringify_annotation(
|
||||
Literal[1, '2', '\r'], 'fully-qualified-except-typing'
|
||||
)
|
||||
@@ -959,7 +959,7 @@ def test_stringify_type_Literal():
|
||||
assert ann_str == '~typing.Literal[MyEnum.a]'
|
||||
|
||||
|
||||
def test_stringify_type_union_operator():
|
||||
def test_stringify_type_union_operator() -> None:
|
||||
assert stringify_annotation(int | None) == 'int | None'
|
||||
assert stringify_annotation(int | None, 'smart') == 'int | None'
|
||||
|
||||
@@ -982,14 +982,14 @@ def test_stringify_type_union_operator():
|
||||
assert stringify_annotation(int | Struct, 'smart') == 'int | ~struct.Struct'
|
||||
|
||||
|
||||
def test_stringify_broken_type_hints():
|
||||
def test_stringify_broken_type_hints() -> None:
|
||||
ann_str = stringify_annotation(BrokenType, 'fully-qualified-except-typing')
|
||||
assert ann_str == 'tests.test_util.test_util_typing.BrokenType'
|
||||
ann_str = stringify_annotation(BrokenType, 'smart')
|
||||
assert ann_str == '~tests.test_util.test_util_typing.BrokenType'
|
||||
|
||||
|
||||
def test_stringify_mock():
|
||||
def test_stringify_mock() -> None:
|
||||
with mock(['unknown']):
|
||||
import unknown
|
||||
|
||||
|
||||
@@ -40,16 +40,16 @@ def is_paragraph(node):
|
||||
return node.__class__.__name__ == 'paragraph'
|
||||
|
||||
|
||||
def test_get_ratio():
|
||||
def test_get_ratio() -> None:
|
||||
assert get_ratio('', 'a')
|
||||
assert get_ratio('a', '')
|
||||
|
||||
|
||||
def test_add_uids():
|
||||
def test_add_uids() -> None:
|
||||
assert len(original_uids) == 3
|
||||
|
||||
|
||||
def test_pickleablility():
|
||||
def test_pickleablility() -> None:
|
||||
# we have to modify the doctree so we can pickle it
|
||||
copy = original.copy()
|
||||
copy.reporter = None
|
||||
@@ -61,7 +61,7 @@ def test_pickleablility():
|
||||
assert all(getattr(n, 'uid', False) for n in loaded.findall(is_paragraph))
|
||||
|
||||
|
||||
def test_modified():
|
||||
def test_modified() -> None:
|
||||
modified = doctrees['modified']
|
||||
new_nodes = list(merge_doctrees(original, modified, is_paragraph))
|
||||
uids = [n.uid for n in modified.findall(is_paragraph)]
|
||||
@@ -69,7 +69,7 @@ def test_modified():
|
||||
assert original_uids == uids
|
||||
|
||||
|
||||
def test_added():
|
||||
def test_added() -> None:
|
||||
added = doctrees['added']
|
||||
new_nodes = list(merge_doctrees(original, added, is_paragraph))
|
||||
uids = [n.uid for n in added.findall(is_paragraph)]
|
||||
@@ -77,7 +77,7 @@ def test_added():
|
||||
assert original_uids == uids[:-1]
|
||||
|
||||
|
||||
def test_deleted():
|
||||
def test_deleted() -> None:
|
||||
deleted = doctrees['deleted']
|
||||
new_nodes = list(merge_doctrees(original, deleted, is_paragraph))
|
||||
uids = [n.uid for n in deleted.findall(is_paragraph)]
|
||||
@@ -85,7 +85,7 @@ def test_deleted():
|
||||
assert original_uids[::2] == uids
|
||||
|
||||
|
||||
def test_deleted_end():
|
||||
def test_deleted_end() -> None:
|
||||
deleted_end = doctrees['deleted_end']
|
||||
new_nodes = list(merge_doctrees(original, deleted_end, is_paragraph))
|
||||
uids = [n.uid for n in deleted_end.findall(is_paragraph)]
|
||||
@@ -93,7 +93,7 @@ def test_deleted_end():
|
||||
assert original_uids[:-1] == uids
|
||||
|
||||
|
||||
def test_insert():
|
||||
def test_insert() -> None:
|
||||
insert = doctrees['insert']
|
||||
new_nodes = list(merge_doctrees(original, insert, is_paragraph))
|
||||
uids = [n.uid for n in insert.findall(is_paragraph)]
|
||||
@@ -102,7 +102,7 @@ def test_insert():
|
||||
assert original_uids[1:] == uids[2:]
|
||||
|
||||
|
||||
def test_insert_beginning():
|
||||
def test_insert_beginning() -> None:
|
||||
insert_beginning = doctrees['insert_beginning']
|
||||
new_nodes = list(merge_doctrees(original, insert_beginning, is_paragraph))
|
||||
uids = [n.uid for n in insert_beginning.findall(is_paragraph)]
|
||||
@@ -112,7 +112,7 @@ def test_insert_beginning():
|
||||
assert original_uids[0] != uids[0]
|
||||
|
||||
|
||||
def test_insert_similar():
|
||||
def test_insert_similar() -> None:
|
||||
insert_similar = doctrees['insert_similar']
|
||||
new_nodes = list(merge_doctrees(original, insert_similar, is_paragraph))
|
||||
uids = [n.uid for n in insert_similar.findall(is_paragraph)]
|
||||
|
||||
Reference in New Issue
Block a user