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..c9acad3f 100644 --- a/numpydoc/tests/hooks/test_validate_hook.py +++ b/numpydoc/tests/hooks/test_validate_hook.py @@ -1,6 +1,7 @@ """Test the numpydoc validate pre-commit hook.""" import inspect +import sys from pathlib import Path 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 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',