Skip to content

Fix #466: CLI pass token for prerelease and build - #467

Draft
tomschr wants to merge 1 commit into
masterfrom
466-token
Draft

tomschr wants to merge 1 commit into
masterfrom
466-token

Conversation

@tomschr

@tomschr tomschr commented Dec 9, 2025

Copy link
Copy Markdown
Member

For the CLI pysemver script, this change introduces a --token option when bumping prereleases or builds.

@killtheprompt

Copy link
Copy Markdown

Local checks against 18149b4 suggest a small CLI test-coverage addition for this draft. The tested head handles these cases correctly; this is not a report of a current functional failure.

The existing CLI tests check default tokens and preconstructed argument namespaces, but do not pass a custom --token through main() and assert its output. As a control, temporarily removing token forwarding still leaves all 27 existing CLI tests passing. The additional cases below catch that mutation in four cases. Token forwarding was restored before the final suite run.

@pytest.mark.parametrize(
    "part,version,token,expected",
    [
        ("prerelease", "1.2.3", None, "1.2.3-rc.1"),
        ("build", "1.2.3", None, "1.2.3+build.1"),
        ("prerelease", "1.2.3", "preview", "1.2.3-preview.1"),
        ("build", "1.2.3", "ci", "1.2.3+ci.1"),
        ("prerelease", "1.2.3", "", "1.2.3-1"),
        ("build", "1.2.3", "", "1.2.3+1"),
        ("prerelease", "1.2.3-8", "preview", "1.2.3-9"),
        ("build", "1.2.3+ci.8", "other", "1.2.3+ci.9"),
    ],
)
def test_should_process_bump_tokens(capsys, part, version, token, expected):
    cli = ["bump", part, version]
    if token is not None:
        cli.extend(["--token", token])

    assert main(cli) == 0
    captured = capsys.readouterr()
    assert captured.out == expected + "\n"
    assert captured.err == ""

These can use the existing imports in tests/test_pysemver-cli.py. None in the table means the option is omitted; the empty string explicitly supplies an empty token. The final two cases retain existing identifiers, consistent with the behavior clarified in #466.

On Python 3.13.16 / pytest 9.1.1, the original suite including doctests passed 354 tests; with these eight cases, 362 passed. Only that Python version was checked, not the whole tox matrix; coverage measurement was not run. Ruff reports the same two pre-existing findings in this test file before and after the addition (I001 and SIM117).

For the CLI pysemver script, this change introduces a --token option
when bumping prereleases or builds.
@tomschr

tomschr commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Thank you very much @killtheprompt! 😍 I've included your suggestion into tests/test_pysemver-cli.py. Many thanks!

This branch has not been deployed

No deployments
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.

2 participants