# HG changeset patch # User RhodeCode Admin # Date 2023-08-25 14:06:54 # Node ID f352498bf64c9b9e95e5018d977e4e97c674dc3a # Parent 3cdc843a4e3d819169bbf9a3004ab1546a1aa453 helpers: fix tests and tag replacers diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1069,7 +1069,8 @@ tags_patterns = OrderedDict( re.compile( r"\[license\ \=\>\ *([a-zA-Z0-9\/\=\?\&\ \:\/\.\-]*)\]" ), - r'
\\1
', + # don't make it a raw string here... + '
\\1
', ), ), ( diff --git a/rhodecode/tests/lib/test_helpers.py b/rhodecode/tests/lib/test_helpers.py --- a/rhodecode/tests/lib/test_helpers.py +++ b/rhodecode/tests/lib/test_helpers.py @@ -28,7 +28,7 @@ from rhodecode.tests import no_newline_i @pytest.mark.parametrize('url, expected_url', [ - (r'https://rc.com', 'http://rc.com'), + (r'https://rc.com', 'https://rc.com'), (r'https://rc.com/test', 'https://rc.com/test'), (r'https://rc.com/!foo', 'https://rc.com/!foo'), (r'https://rc.com/&foo', 'https://rc.com/&foo'), @@ -131,13 +131,13 @@ def test_extract_issues(backend, text_st @pytest.mark.parametrize('text_string, pattern, link_format, expected_text', [ ('Fix #42', '(?:#)(?P\d+)', 'html', - 'Fix #42'), + 'Fix #42'), ('Fix #42', '(?:#)(?P\d+)', 'markdown', - 'Fix [#42](http://r.io/{repo}/i/42)'), + 'Fix [#42](https://r.io/{repo}/i/42)'), ('Fix #42', '(?:#)(?P\d+)', 'rst', - 'Fix `#42 `_'), + 'Fix `#42 `_'), ('Fix #42', '(?:#)?\d+)', 'html', 'Fix #42'), # Broken regex @@ -150,7 +150,7 @@ def test_process_patterns_repo(backend, '123': { 'uid': '123', 'pat': pattern, - 'url': 'http://r.io/${repo}/i/${issue_id}', + 'url': 'https://r.io/${repo}/i/${issue_id}', 'pref': '#', 'desc': 'Test Pattern' } @@ -166,7 +166,7 @@ def test_process_patterns_repo(backend, @pytest.mark.parametrize('text_string, pattern, expected_text', [ ('Fix #42', '(?:#)(?P\d+)', - 'Fix #42'), + 'Fix #42'), ('Fix #42', '(?:#)?\d+)', 'Fix #42'), # Broken regex ]) @@ -177,7 +177,7 @@ def test_process_patterns_no_repo(text_s '123': { 'uid': '123', 'pat': pattern, - 'url': 'http://r.io/i/${issue_id}', + 'url': 'https://r.io/i/${issue_id}', 'pref': '#', 'desc': 'Test Pattern' } @@ -193,16 +193,16 @@ def test_process_patterns_no_repo(text_s def test_process_patterns_non_existent_repo_name(backend): text_string = 'Fix #42' - pattern = '(?:#)(?P\d+)' + pattern = r'(?:#)(?P\d+)' expected_text = ('Fix #42') + 'href="https://r.io/do-not-exist/i/42" title="Test Pattern">#42') def get_settings_mock(self, cache=True): return { '123': { 'uid': '123', 'pat': pattern, - 'url': 'http://r.io/${repo}/i/${issue_id}', + 'url': 'https://r.io/${repo}/i/${issue_id}', 'pref': '#', 'desc': 'Test Pattern' }