diff --git a/numpydoc/tests/hooks/test_utils.py b/numpydoc/tests/hooks/test_utils.py index 5db63762..7aa11cf3 100644 --- a/numpydoc/tests/hooks/test_utils.py +++ b/numpydoc/tests/hooks/test_utils.py @@ -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: diff --git a/numpydoc/tests/hooks/test_validate_hook.py b/numpydoc/tests/hooks/test_validate_hook.py index 7d4d2378..85fc346e 100644 --- a/numpydoc/tests/hooks/test_validate_hook.py +++ b/numpydoc/tests/hooks/test_validate_hook.py @@ -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 """ ) @@ -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 """ ) @@ -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 """ ) @@ -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 """ ) @@ -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 """ ) @@ -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 """ ) @@ -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 @@ -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 diff --git a/pyproject.toml b/pyproject.toml index cfc58d90..ae6e7b96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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',