Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion numpydoc/tests/hooks/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ def test_find_project_root(tmp_path, request, reason_file, files, expected_reaso
(tmp_path / reason_file).touch()

if files:
expected_dir = Path("/") if expected_reason == "file system root" else tmp_path
expected_dir = (
Path(tmp_path.anchor) if expected_reason == "file system root" else tmp_path
)

for file in files:
(tmp_path / file).touch()
else:
Expand Down
90 changes: 45 additions & 45 deletions numpydoc/tests/hooks/test_validate_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,42 @@ def test_validate_hook(example_module, config, capsys):
"""Test that a file is correctly processed in the absence of config files."""

expected = inspect.cleandoc(
"""
numpydoc/tests/hooks/example_module.py:4: ES01 No extended summary found
f"""
{example_module!s}:4: ES01 No extended summary found

numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
{example_module!s}:4: PR01 Parameters {{'name'}} not documented

numpydoc/tests/hooks/example_module.py:4: SA01 See Also section not found
{example_module!s}:4: SA01 See Also section not found

numpydoc/tests/hooks/example_module.py:4: EX01 No examples section found
{example_module!s}:4: EX01 No examples section found

numpydoc/tests/hooks/example_module.py:8: ES01 No extended summary found
{example_module!s}:8: ES01 No extended summary found

numpydoc/tests/hooks/example_module.py:8: SA01 See Also section not found
{example_module!s}:8: SA01 See Also section not found

numpydoc/tests/hooks/example_module.py:8: EX01 No examples section found
{example_module!s}:8: EX01 No examples section found

numpydoc/tests/hooks/example_module.py:11: GL08 The object does not have a docstring
{example_module!s}:11: GL08 The object does not have a docstring

numpydoc/tests/hooks/example_module.py:17: ES01 No extended summary found
{example_module!s}:17: ES01 No extended summary found

numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented

numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
{example_module!s}:17: PR07 Parameter "*args" has no description

numpydoc/tests/hooks/example_module.py:17: SA01 See Also section not found
{example_module!s}:17: SA01 See Also section not found

numpydoc/tests/hooks/example_module.py:17: EX01 No examples section found
{example_module!s}:17: EX01 No examples section found

numpydoc/tests/hooks/example_module.py:26: SS05 Summary must start with infinitive verb, not third person (e.g. use "Generate" instead of "Generates")
{example_module!s}:26: SS05 Summary must start with infinitive verb, not third person (e.g. use "Generate" instead of "Generates")

numpydoc/tests/hooks/example_module.py:26: ES01 No extended summary found
{example_module!s}:26: ES01 No extended summary found

numpydoc/tests/hooks/example_module.py:26: SA01 See Also section not found
{example_module!s}:26: SA01 See Also section not found

numpydoc/tests/hooks/example_module.py:26: EX01 No examples section found
{example_module!s}:26: EX01 No examples section found

numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
{example_module!s}:30: GL08 The object does not have a docstring
"""
)

Expand All @@ -76,18 +76,18 @@ def test_validate_hook_with_ignore(example_module, capsys):
"""

expected = inspect.cleandoc(
"""
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
f"""
{example_module!s}:4: PR01 Parameters {{'name'}} not documented

numpydoc/tests/hooks/example_module.py:11: GL08 The object does not have a docstring
{example_module!s}:11: GL08 The object does not have a docstring

numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented

numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
{example_module!s}:17: PR07 Parameter "*args" has no description

numpydoc/tests/hooks/example_module.py:26: SS05 Summary must start with infinitive verb, not third person (e.g. use "Generate" instead of "Generates")
{example_module!s}:26: SS05 Summary must start with infinitive verb, not third person (e.g. use "Generate" instead of "Generates")

numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
{example_module!s}:30: GL08 The object does not have a docstring
"""
)

Expand Down Expand Up @@ -123,14 +123,14 @@ def test_validate_hook_with_toml_config(example_module, tmp_path, capsys):
)

expected = inspect.cleandoc(
"""
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
f"""
{example_module!s}:4: PR01 Parameters {{'name'}} not documented

numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented

numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
{example_module!s}:17: PR07 Parameter "*args" has no description

numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
{example_module!s}:30: GL08 The object does not have a docstring
"""
)

Expand Down Expand Up @@ -158,14 +158,14 @@ def test_validate_hook_with_setup_cfg(example_module, tmp_path, capsys):
)

expected = inspect.cleandoc(
"""
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
f"""
{example_module!s}:4: PR01 Parameters {{'name'}} not documented

numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented

numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
{example_module!s}:17: PR07 Parameter "*args" has no description

numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
{example_module!s}:30: GL08 The object does not have a docstring
"""
)

Expand Down Expand Up @@ -203,10 +203,10 @@ def test_validate_hook_exclude_option_pyproject(example_module, tmp_path, capsys
)

expected = inspect.cleandoc(
"""
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
f"""
{example_module!s}:4: PR01 Parameters {{'name'}} not documented

numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring
{example_module!s}:30: GL08 The object does not have a docstring
"""
)

Expand Down Expand Up @@ -234,12 +234,12 @@ def test_validate_hook_exclude_option_setup_cfg(example_module, tmp_path, capsys
)

expected = inspect.cleandoc(
"""
numpydoc/tests/hooks/example_module.py:4: PR01 Parameters {'name'} not documented
f"""
{example_module!s}:4: PR01 Parameters {{'name'}} not documented

numpydoc/tests/hooks/example_module.py:17: PR01 Parameters {'**kwargs'} not documented
{example_module!s}:17: PR01 Parameters {{'**kwargs'}} not documented

numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description
{example_module!s}:17: PR07 Parameter "*args" has no description
"""
)

Expand All @@ -250,7 +250,7 @@ def test_validate_hook_exclude_option_setup_cfg(example_module, tmp_path, capsys

@pytest.mark.parametrize(
"regex, expected_code",
[(r".*(/|\\\\)example.*\.py", 0), (r".*/non_existent_match.*\.py", 1)],
[(".*(/|\\\\)example.*\.py", 0), (".*/non_existent_match.*\.py", 1)],
)
def test_validate_hook_exclude_files_option_pyproject(
example_module, regex, expected_code, tmp_path
Expand Down Expand Up @@ -287,7 +287,7 @@ def test_validate_hook_exclude_files_option_pyproject(

@pytest.mark.parametrize(
"regex, expected_code",
[(r".*(/|\\\\)example.*\.py", 0), (r".*/non_existent_match.*\.py", 1)],
[(".*(/|\\\\)example.*\.py", 0), (".*/non_existent_match.*\.py", 1)],
)
def test_validate_hook_exclude_files_option_setup_cfg(
example_module, regex, expected_code, tmp_path
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ attr = 'numpydoc.__version__'
[tool.setuptools.package-data]
numpydoc = [
'tests/test_*.py',
'tests/hooks/test_*.py',
'tests/tinybuild/Makefile',
'tests/tinybuild/index.rst',
'tests/tinybuild/*.py',
Expand Down
Loading