From a2aa51f5702b18016c25d943499941323952704d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 19 Nov 2022 15:52:46 +0100 Subject: Adding upstream version 0.18.0. Signed-off-by: Daniel Baumann --- gitlint-core/gitlint/tests/test_deprecation.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 gitlint-core/gitlint/tests/test_deprecation.py (limited to 'gitlint-core/gitlint/tests/test_deprecation.py') 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")]) -- cgit v1.2.3