Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1509aa0
docs: add pytest test reorganization plan
derek73 Jun 14, 2026
03cae7a
test: scaffold pytest package with dual-run fixture and first module
derek73 Jun 14, 2026
06c0806
docs: account for @unittest.expectedFailure -> pytest.mark.xfail in plan
derek73 Jun 14, 2026
9b4a632
test: move HumanNamePythonTests to tests/test_python_api.py
derek73 Jun 14, 2026
1117dbd
test: move HumanNameBruteForceTests to tests/test_brute_force.py
derek73 Jun 14, 2026
8fddb99
test: move HumanNameConjunctionTestCase to tests/test_conjunctions.py
derek73 Jun 14, 2026
f6ed8fe
test: move ConstantsCustomization to tests/test_constants.py and rena…
derek73 Jun 14, 2026
526b4f3
docs: correct method counts in plan (345 total, Constants has 12)
derek73 Jun 14, 2026
030174e
test: move NicknameTestCase to tests/test_nicknames.py
derek73 Jun 14, 2026
350590c
test: move PrefixesTestCase to tests/test_prefixes.py
derek73 Jun 14, 2026
4c91872
test: move SuffixesTestCase to tests/test_suffixes.py
derek73 Jun 14, 2026
7bae8bc
test: move TitleTestCase to tests/test_titles.py
derek73 Jun 14, 2026
a85e003
test: move HumanNameCapitalizationTestCase to tests/test_capitalizati…
derek73 Jun 14, 2026
b5d2a9f
docs: fix Task 11/12 headers (config imported locally, not top-level)
derek73 Jun 14, 2026
962d629
test: move HumanNameOutputFormatTests to tests/test_output_format.py
derek73 Jun 14, 2026
dcb6ca0
test: move InitialsTestCase to tests/test_initials.py
derek73 Jun 14, 2026
902c80a
fix: initials() renders empty parts as '' instead of literal None
derek73 Jun 14, 2026
c54994a
test: snapshot/restore global CONSTANTS scalars to isolate tests
derek73 Jun 14, 2026
289bc02
test: complete InitialsTestCase move; drop fabricated constants test
derek73 Jun 14, 2026
bee04df
docs: restore plan counts to 344 methods (688 collected)
derek73 Jun 14, 2026
fd2018a
test: move TEST_NAMES and HumanNameVariationTests to tests/test_varia…
derek73 Jun 14, 2026
374d228
feat: add 'python -m nameparser' debug CLI; remove monolithic tests.py
derek73 Jun 14, 2026
5adb8ed
docs: update test instructions and CI for pytest
derek73 Jun 14, 2026
b68ef39
build: include tests/ package in sdist instead of deleted tests.py
derek73 Jun 14, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: mypy
- name: Run Tests
run: |
python tests.py
pytest
python -m build --sdist
twine check dist/*
sphinx-build -b html docs dist/docs
13 changes: 7 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
pip install --group dev

# Run all tests
python tests.py
pytest

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

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

# Build docs
sphinx-build -b html docs dist/docs
Expand Down Expand Up @@ -65,6 +66,6 @@ Parse flow:

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.

### Tests (`tests.py`)
### Tests (`tests/`)

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`.
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`.
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ Install dev dependencies:
Running Tests
---------------

python tests.py
pytest

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

$ python tests.py "Secretary of State Hillary Rodham-Clinton"
pytest tests/test_titles.py
pytest tests/test_titles.py::TitleTestCase

You can also pass a name string to see how it will be parsed:

$ python -m nameparser "Secretary of State Hillary Rodham-Clinton"
<HumanName : [
Title: 'Secretary of State'
First: 'Hillary'
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include AUTHORS
include LICENSE
include README.rst
include tests.py
recursive-include tests *.py
Loading