Skip to content

Commit

Permalink
Add return annotation to several zero-argument test functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Feb 15, 2025
1 parent 2364f16 commit a980fbc
Show file tree
Hide file tree
Showing 44 changed files with 246 additions and 244 deletions.
2 changes: 1 addition & 1 deletion tests/test_builders/test_build_html_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_builders/test_build_manpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def ruby?
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",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_builders/test_build_texinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 12 additions & 12 deletions tests/test_config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
{
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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})

Expand All @@ -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})

Expand All @@ -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})

Expand All @@ -752,31 +752,31 @@ 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
# https://github.com/sphinx-doc/sphinx/issues/13071
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
# https://github.com/sphinx-doc/sphinx/issues/13071
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
# https://github.com/sphinx-doc/sphinx/issues/13071
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})

Expand All @@ -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(
Expand All @@ -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
Expand Down
30 changes: 15 additions & 15 deletions tests/test_domains/test_domain_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -336,7 +336,7 @@ def expr_check(expr, output=None):
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
Expand Down Expand Up @@ -403,7 +403,7 @@ def signed(t):
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')
Expand All @@ -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'})
Expand All @@ -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'})
Expand Down Expand Up @@ -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'})
Expand Down Expand Up @@ -570,37 +570,37 @@ 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]')
check('struct', '@1', {1: '@1'}, as_text_output='struct [anonymous]')
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
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit a980fbc

Please sign in to comment.