Add set_version encoding tests and fix missing encoding in provider writes #1859
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds tests for
set_version()methods to verify encoding behavior during version updates (thecz bumppath). While adding tests, discovered multiple providers weren't using configured encoding when writing files.Tests Added
test_json_provider_set_version_uses_encoding_with_encoding_fixture- Verifies JsonProvider writes non-ASCII content correctlytest_toml_provider_set_version_uses_encoding_with_encoding_fixture- Verifies TomlProvider writes non-ASCII content correctlyBoth tests use existing fixtures with Cyrillic characters and verify version updates preserve non-ASCII content.
Encoding Bugs Fixed
encodingparameter andensure_ascii=Falseencodingparameter_get_encoding()method; applied to all file operations (package.json, package-lock.json, npm-shrinkwrap.json)Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot following the guidelines
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsDocumentation Changes
uv run poe doclocally to ensure the documentation pages renders correctlyExpected Behavior
Version files containing non-ASCII characters (e.g., UTF-8 with Cyrillic, emoji, CJK) should maintain encoding integrity through
get_version()andset_version()operations when encoding is configured.Steps to Test This Pull Request
python -m pytest tests/providers/test_base_provider.py -vset_versiontestspython -m pytest tests/providers/test_npm_provider.py tests/providers/test_cargo_provider.py -vAdditional Context
Addresses feedback from #1857 review comment requesting
set_version()test coverage. The encoding bugs were latent issues - existingget_version()tests only caught half the problem.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.