diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-19 14:52:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-19 14:52:46 +0000 |
commit | a2aa51f5702b18016c25d943499941323952704d (patch) | |
tree | 7ee43f79639ee53903e7ca389e548974e1497c3a /gitlint-core/gitlint/tests/test_deprecation.py | |
parent | Adding upstream version 0.17.0. (diff) | |
download | gitlint-a2aa51f5702b18016c25d943499941323952704d.tar.xz gitlint-a2aa51f5702b18016c25d943499941323952704d.zip |
Adding upstream version 0.18.0.upstream/0.18.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gitlint-core/gitlint/tests/test_deprecation.py')
-rw-r--r-- | gitlint-core/gitlint/tests/test_deprecation.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gitlint-core/gitlint/tests/test_deprecation.py b/gitlint-core/gitlint/tests/test_deprecation.py new file mode 100644 index 0000000..d85593a --- /dev/null +++ b/gitlint-core/gitlint/tests/test_deprecation.py @@ -0,0 +1,23 @@ +from gitlint.config import LintConfig +from gitlint.deprecation import Deprecation +from gitlint.rules import IgnoreByTitle +from gitlint.tests.base import EXPECTED_REGEX_STYLE_SEARCH_DEPRECATION_WARNING, BaseTestCase + + +class DeprecationTests(BaseTestCase): + def test_get_regex_method(self): + config = LintConfig() + Deprecation.config = config + rule = IgnoreByTitle({"regex": "^ReleƤse(.*)"}) + + # When general.regex-style-search=True, we expect regex.search to be returned and no warning to be logged + config.regex_style_search = True + regex_method = Deprecation.get_regex_method(rule, rule.options["regex"]) + self.assertEqual(regex_method, rule.options["regex"].value.search) + self.assert_logged([]) + + # When general.regex-style-search=False, we expect regex.match to be returned and a warning to be logged + config.regex_style_search = False + regex_method = Deprecation.get_regex_method(rule, rule.options["regex"]) + self.assertEqual(regex_method, rule.options["regex"].value.match) + self.assert_logged([EXPECTED_REGEX_STYLE_SEARCH_DEPRECATION_WARNING.format("I1", "ignore-by-title")]) |