From e728f6197afa4c38cb13b96847fea1ed8c87fcdc Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Sat, 18 Oct 2025 10:49:02 -0700 Subject: [PATCH 1/3] MAINT: Add missing hooks tests. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index b8911d85..289eb609 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -169,6 +169,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', From ced91b620f04ddb02cc45f1f32cbf56889ab46f8 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Fri, 17 Oct 2025 13:55:14 -0700 Subject: [PATCH 2/3] TST: Fix hook tests for windows. * replace path separators on windows * Add drive to path for windows --- numpydoc/tests/hooks/test_utils.py | 6 +++++- numpydoc/tests/hooks/test_validate_hook.py | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/numpydoc/tests/hooks/test_utils.py b/numpydoc/tests/hooks/test_utils.py index 5db63762..918b9045 100644 --- a/numpydoc/tests/hooks/test_utils.py +++ b/numpydoc/tests/hooks/test_utils.py @@ -23,7 +23,11 @@ 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 + if expected_reason == "file system root": + expected_dir = Path(tmp_path.drive + tmp_path.root) + else: + expected_dir = 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 b235313b..ffa0e473 100644 --- a/numpydoc/tests/hooks/test_validate_hook.py +++ b/numpydoc/tests/hooks/test_validate_hook.py @@ -2,6 +2,7 @@ import inspect from pathlib import Path +import sys import pytest @@ -63,6 +64,8 @@ def test_validate_hook(example_module, config, capsys): numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring """ ) + if sys.platform == "win32": + expected = expected.replace("/", "\\") return_code = run_hook([example_module], config=config) assert return_code == 1 @@ -90,6 +93,8 @@ def test_validate_hook_with_ignore(example_module, capsys): numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring """ ) + if sys.platform == "win32": + expected = expected.replace("/", "\\") return_code = run_hook([example_module], ignore=["ES01", "SA01", "EX01"]) @@ -133,6 +138,8 @@ def test_validate_hook_with_toml_config(example_module, tmp_path, capsys): numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring """ ) + if sys.platform == "win32": + expected = expected.replace("/", "\\") return_code = run_hook([example_module], config=tmp_path) assert return_code == 1 @@ -168,6 +175,8 @@ def test_validate_hook_with_setup_cfg(example_module, tmp_path, capsys): numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring """ ) + if sys.platform == "win32": + expected = expected.replace("/", "\\") return_code = run_hook([example_module], config=tmp_path) assert return_code == 1 @@ -209,6 +218,8 @@ def test_validate_hook_exclude_option_pyproject(example_module, tmp_path, capsys numpydoc/tests/hooks/example_module.py:30: GL08 The object does not have a docstring """ ) + if sys.platform == "win32": + expected = expected.replace("/", "\\") return_code = run_hook([example_module], config=tmp_path) assert return_code == 1 @@ -242,6 +253,8 @@ def test_validate_hook_exclude_option_setup_cfg(example_module, tmp_path, capsys numpydoc/tests/hooks/example_module.py:17: PR07 Parameter "*args" has no description """ ) + if sys.platform == "win32": + expected = expected.replace("/", "\\") return_code = run_hook([example_module], config=tmp_path) assert return_code == 1 From 706ed1062b50657991fd596b08de13cc6b5a798a Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Sat, 18 Oct 2025 12:26:26 -0700 Subject: [PATCH 3/3] Lint. --- numpydoc/tests/hooks/test_validate_hook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpydoc/tests/hooks/test_validate_hook.py b/numpydoc/tests/hooks/test_validate_hook.py index ffa0e473..c9acad3f 100644 --- a/numpydoc/tests/hooks/test_validate_hook.py +++ b/numpydoc/tests/hooks/test_validate_hook.py @@ -1,8 +1,8 @@ """Test the numpydoc validate pre-commit hook.""" import inspect -from pathlib import Path import sys +from pathlib import Path import pytest