Skip to content

Add pluralize utility with unit tests - #1682

Open
Copilot wants to merge 2 commits into
mainfrom
copilot/add-pluralize-utility
Open

Add pluralize utility with unit tests#1682
Copilot wants to merge 2 commits into
mainfrom
copilot/add-pluralize-utility

Conversation

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown

Summary

Adds a small, reusable pluralize utility to bowtie/_utils.py and covers it with unit tests + doctests.

Bowtie's CLI (bowtie/_cli.py) had duplicated inline pluralization logic in two places:

test = "tests" if summary.total_tests != 1 else "test"
...
caption=f"{summary.total_tests} {test} ran",

This extracts that into bowtie._utils.pluralize(count, noun, plural=None) and updates both call sites to use it.

Changes

  • bowtie/_utils.py (new): pluralize helper with doctests
  • bowtie/_cli.py: refactor both duplicated pluralization call sites to use the new helper
  • tests/test_utils.py (new): unit tests covering singular, plural, zero, negative counts, and custom plural forms

Validation

  • pytest tests/test_utils.py - 6 passed
  • python -m doctest bowtie/_utils.py - all doctests passed
  • ruff check on changed files - all checks passed

Copilot and others added 2 commits August 6, 2026 09:17
Extract duplicated pluralization logic from bowtie/_cli.py into a small,
reusable bowtie._utils.pluralize helper, and cover it with unit tests
and doctests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant