Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 345
test: use match in pytest.raises#1846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import re | ||
| from collections.abc import Callable | ||
| from pathlib import Path | ||
| from shutil import copyfile | ||
| @@ -199,7 +200,14 @@ def test_file_version_inconsistent_error( | ||
| ] | ||
| old_version = "1.2.3" | ||
| new_version = "2.0.0" | ||
| with pytest.raises(CurrentVersionNotFoundError) as excinfo: | ||
| with pytest.raises( | ||
| CurrentVersionNotFoundError, | ||
| match=re.escape( | ||
| f"Current version {old_version} is not found in {inconsistent_python_version_file}.\n" | ||
| "The version defined in commitizen configuration and the ones in " | ||
| "version_files are possibly inconsistent." | ||
| ), | ||
| ): | ||
| bump.update_version_in_files( | ||
| old_version, | ||
| new_version, | ||
| @@ -208,13 +216,6 @@ def test_file_version_inconsistent_error( | ||
| encoding="utf-8", | ||
| ) | ||
| expected_msg = ( | ||
| f"Current version 1.2.3 is not found in {inconsistent_python_version_file}.\n" | ||
| "The version defined in commitizen configuration and the ones in " | ||
| "version_files are possibly inconsistent." | ||
| ) | ||
| assert expected_msg in str(excinfo.value) | ||
| def test_multiple_versions_to_bump( | ||
| multiple_versions_to_update_poetry_lock, file_regression | ||
| @@ -285,7 +286,14 @@ def test_update_version_in_files_with_check_consistency_true_failure( | ||
| version_files = [commitizen_config_file, inconsistent_python_version_file] | ||
| # This should fail because inconsistent_python_version_file doesn't contain the current version | ||
| with pytest.raises(CurrentVersionNotFoundError) as excinfo: | ||
| with pytest.raises( | ||
| CurrentVersionNotFoundError, | ||
| match=re.escape( | ||
| f"Current version {old_version} is not found in {inconsistent_python_version_file}.\n" | ||
| "The version defined in commitizen configuration and the ones in " | ||
| "version_files are possibly inconsistent." | ||
| ), | ||
| ): | ||
Lee-W marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| bump.update_version_in_files( | ||
| old_version, | ||
| new_version, | ||
| @@ -294,13 +302,6 @@ def test_update_version_in_files_with_check_consistency_true_failure( | ||
| encoding="utf-8", | ||
| ) | ||
| expected_msg = ( | ||
| f"Current version {old_version} is not found in {inconsistent_python_version_file}.\n" | ||
| "The version defined in commitizen configuration and the ones in " | ||
| "version_files are possibly inconsistent." | ||
| ) | ||
| assert expected_msg in str(excinfo.value) | ||
| @pytest.mark.parametrize( | ||
| ("encoding", "filename"), | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.