Skip to content

Commit 5adb8ed

Browse files
derek73claude
andcommitted
docs: update test instructions and CI for pytest
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 374d228 commit 5adb8ed

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run: mypy
4141
- name: Run Tests
4242
run: |
43-
python tests.py
43+
pytest
4444
python -m build --sdist
4545
twine check dist/*
4646
sphinx-build -b html docs dist/docs

AGENTS.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
99
pip install --group dev
1010

1111
# Run all tests
12-
python tests.py
12+
pytest
1313

14-
# Run a single test by class/method
15-
python -m unittest tests.HumanNamePythonTests.test_utf8
14+
# Run a single test file / class / method
15+
pytest tests/test_python_api.py
16+
pytest tests/test_python_api.py::HumanNamePythonTests::test_utf8
1617

1718
# Debug how a specific name string is parsed (prints HumanName repr)
18-
python tests.py "Dr. Juan Q. Xavier de la Vega III"
19+
python -m nameparser "Dr. Juan Q. Xavier de la Vega III"
1920

2021
# Build docs
2122
sphinx-build -b html docs dist/docs
@@ -65,6 +66,6 @@ Parse flow:
6566

6667
Each named attribute (`title`, `first`, etc.) is a `@property` that joins its corresponding `_list`. Setters call `_set_list()` which runs the value through `parse_pieces()`, so assigning `hn.last = "de la Vega"` correctly re-parses prefix tokens.
6768

68-
### Tests (`tests.py`)
69+
### Tests (`tests/`)
6970

70-
All tests live in a single file. `HumanNameTestBase.m()` is a custom assert helper that prints the original name string on failure. Many test classes group cases by name format type. `TEST_NAMES` is a list of name strings that gets automatically permuted into comma-separated variants as a regression check. When adding a new parsing case, add it to the relevant test class and consider adding the base form to `TEST_NAMES`.
71+
Tests run under **pytest** and are split one file per concern (`tests/test_titles.py`, `tests/test_suffixes.py`, etc.). `tests/base.py` holds `HumanNameTestBase` — a plain (non-`unittest`) base whose `m()` helper is a custom assert that prints the original name string on failure (plus thin `assert*` shims so the moved test bodies are unchanged). `tests/conftest.py` defines an autouse fixture that runs **every test twice** — once with `empty_attribute_default = ''` and once with `None` — so reported counts are doubled (e.g. 11 methods → 22 results); it also snapshots/restores the scalar `CONSTANTS` config around each test to keep tests order-independent. `TEST_NAMES` (in `tests/test_variations.py`) is a list of name strings permuted into comma-separated variants as a regression check. Tests that should fail use `@pytest.mark.xfail`. When adding a parsing case, add it to the relevant `tests/test_*.py` file and consider adding the base form to `TEST_NAMES`.

CONTRIBUTING.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ Install dev dependencies:
1111
Running Tests
1212
---------------
1313

14-
python tests.py
14+
pytest
1515

16-
You can also pass a name string to `tests.py` to see how it will be parsed:
16+
Run a single test file or test:
1717

18-
$ python tests.py "Secretary of State Hillary Rodham-Clinton"
18+
pytest tests/test_titles.py
19+
pytest tests/test_titles.py::TitleTestCase
20+
21+
You can also pass a name string to see how it will be parsed:
22+
23+
$ python -m nameparser "Secretary of State Hillary Rodham-Clinton"
1924
<HumanName : [
2025
Title: 'Secretary of State'
2126
First: 'Hillary'

0 commit comments

Comments
 (0)