|
3 | 3 | from commitizen import changelog_formats, defaults |
4 | 4 |
|
5 | 5 |
|
6 | | -def test_getattr_deprecated_vars(): |
| 6 | +@pytest.mark.parametrize( |
| 7 | + ("deprecated_var_getter", "replacement"), |
| 8 | + [ |
| 9 | + (lambda: defaults.bump_pattern, defaults.BUMP_PATTERN), |
| 10 | + (lambda: defaults.bump_map, defaults.BUMP_MAP), |
| 11 | + ( |
| 12 | + lambda: defaults.bump_map_major_version_zero, |
| 13 | + defaults.BUMP_MAP_MAJOR_VERSION_ZERO, |
| 14 | + ), |
| 15 | + (lambda: defaults.bump_message, defaults.BUMP_MESSAGE), |
| 16 | + (lambda: defaults.change_type_order, defaults.CHANGE_TYPE_ORDER), |
| 17 | + (lambda: defaults.encoding, defaults.ENCODING), |
| 18 | + (lambda: defaults.name, defaults.DEFAULT_SETTINGS["name"]), |
| 19 | + ( |
| 20 | + lambda: changelog_formats.guess_changelog_format, |
| 21 | + changelog_formats._guess_changelog_format, |
| 22 | + ), |
| 23 | + ], |
| 24 | +) |
| 25 | +def test_getattr_deprecated_vars(deprecated_var_getter, replacement): |
7 | 26 | # Test each deprecated variable |
8 | 27 | with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): |
9 | | - assert defaults.bump_pattern == defaults.BUMP_PATTERN |
10 | | - with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): |
11 | | - assert defaults.bump_map == defaults.BUMP_MAP |
12 | | - with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): |
13 | | - assert ( |
14 | | - defaults.bump_map_major_version_zero == defaults.BUMP_MAP_MAJOR_VERSION_ZERO |
15 | | - ) |
16 | | - with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): |
17 | | - assert defaults.bump_message == defaults.BUMP_MESSAGE |
18 | | - with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): |
19 | | - assert defaults.change_type_order == defaults.CHANGE_TYPE_ORDER |
20 | | - with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): |
21 | | - assert defaults.encoding == defaults.ENCODING |
22 | | - with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): |
23 | | - assert defaults.name == defaults.DEFAULT_SETTINGS["name"] |
24 | | - with pytest.warns(DeprecationWarning, match="is deprecated and will be removed"): |
25 | | - assert ( |
26 | | - changelog_formats._guess_changelog_format |
27 | | - == changelog_formats.guess_changelog_format |
28 | | - ) |
| 28 | + val = deprecated_var_getter() |
| 29 | + assert val == replacement |
29 | 30 |
|
30 | 31 |
|
31 | 32 | def test_getattr_non_existent(): |
32 | 33 | # Test non-existent attribute |
33 | | - with pytest.raises(AttributeError) as exc_info: |
| 34 | + with pytest.raises(AttributeError, match="is not an attribute of"): |
34 | 35 | _ = defaults.non_existent_attribute |
35 | | - assert "is not an attribute of" in str(exc_info.value) |
0 commit comments