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
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,42 @@ jobs:
- name: Test coverage
run: |
codecov

test-sdist:
runs-on: ${{ matrix.os }}-latest
strategy:
matrix:
os: [ubuntu]
python-version: ["3.14"]
steps:
- uses: actions/checkout@v5

- name: Python setup
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Setup environment
run: |
python -m pip install --upgrade pip wheel setuptools build
python -m pip list

- name: Install dependencies
run: |
python -m pip install --group test --group doc
pip list

- name: Build numpydoc
run: python -m build

- name: Install numpydoc from source tarball
run: |
python -m pip install --no-binary numpydoc dist/*.tar.gz
pip list

- name: Run test suite
# NOTE: Move outside of source directory to prevent any file pickup -
# ensure all tests/tests files are derived from the package *only*
run: |
mkdir foo && cd foo
pytest -v --pyargs numpydoc
2 changes: 1 addition & 1 deletion numpydoc/tests/hooks/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_find_project_root(tmp_path, request, reason_file, files, expected_reaso
for file in files:
(tmp_path / file).touch()
else:
expected_dir = request.config.rootdir
expected_dir = Path.cwd()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this change is necessary to accommodate the running of tests from a different location, as there is then a difference between the root_dir reported by the request fixture and the location where the tests are being run.


root_dir, reason = utils.find_project_root(files if not files else [tmp_path])
assert reason == expected_reason
Expand Down
17 changes: 9 additions & 8 deletions numpydoc/tests/hooks/test_validate_hook.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
"""Test the numpydoc validate pre-commit hook."""

import importlib.resources
import inspect
import re
from pathlib import Path

import pytest

import numpydoc
from numpydoc.hooks.validate_docstrings import run_hook


@pytest.fixture
def example_module(request):
fullpath = (
Path(request.config.rootdir)
/ "numpydoc"
/ "tests"
/ "hooks"
/ "example_module.py"
)
return str(fullpath.relative_to(request.config.rootdir))
# TODO: When Python3.13 is the minimum version supported version, this
# can be simplified to:
# with importlib.resources.path(numpydoc, "tests/hooks/example_module.py") as fpath:
# fullpath = str(fpath)
with importlib.resources.path(numpydoc, "tests") as fpath:
fullpath = str(fpath / "hooks/example_module.py")
return str(fullpath)


@pytest.mark.parametrize("config", [None, "fake_dir"])
Expand Down
8 changes: 6 additions & 2 deletions numpydoc/tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib.resources
import inspect
import io
import sys
Expand Down Expand Up @@ -119,12 +120,15 @@ def test_validate_perfect_docstring():

@pytest.mark.parametrize("args", [[], ["--ignore", "SS03"]])
def test_lint(capsys, args):
argv = ["lint", "numpydoc/__main__.py"] + args
with importlib.resources.path(numpydoc, "__main__.py") as fpath:
strpath = str(fpath)

argv = ["lint", strpath] + args
if args:
expected = ""
expected_status = 0
else:
expected = "numpydoc/__main__.py:1: SS03 Summary does not end with a period"
expected = f"{strpath}:1: SS03 Summary does not end with a period"
expected_status = 1

return_status = numpydoc.cli.main(argv)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ attr = 'numpydoc.__version__'
[tool.setuptools.package-data]
numpydoc = [
'tests/test_*.py',
'tests/hooks/test_*.py',
'tests/hooks/*.py',
'tests/tinybuild/Makefile',
'tests/tinybuild/index.rst',
'tests/tinybuild/*.py',
Expand Down