##// END OF EJS Templates
chore(regex): properly escape \d used in regexes
super-admin -
r5187:51a848c7 default
parent child Browse files
Show More
@@ -96,12 +96,12 b' def test_format_binary():'
96
96
97 @pytest.mark.parametrize('text_string, pattern, expected', [
97 @pytest.mark.parametrize('text_string, pattern, expected', [
98 ('No issue here', r'(?:#)(?P<issue_id>\d+)', []),
98 ('No issue here', r'(?:#)(?P<issue_id>\d+)', []),
99 ('Fix #42', '(?:#)(?P<issue_id>\d+)',
99 ('Fix #42', r'(?:#)(?P<issue_id>\d+)',
100 [{'url': 'https://r.io/{repo}/i/42', 'id': '42'}]),
100 [{'url': 'https://r.io/{repo}/i/42', 'id': '42'}]),
101 ('Fix #42, #53', '(?:#)(?P<issue_id>\d+)', [
101 ('Fix #42, #53', r'(?:#)(?P<issue_id>\d+)', [
102 {'url': 'https://r.io/{repo}/i/42', 'id': '42'},
102 {'url': 'https://r.io/{repo}/i/42', 'id': '42'},
103 {'url': 'https://r.io/{repo}/i/53', 'id': '53'}]),
103 {'url': 'https://r.io/{repo}/i/53', 'id': '53'}]),
104 ('Fix #42', '(?:#)?<issue_id>\d+)', []), # Broken regex
104 ('Fix #42', r'(?:#)?<issue_id>\d+)', []), # Broken regex
105 ])
105 ])
106 def test_extract_issues(backend, text_string, pattern, expected):
106 def test_extract_issues(backend, text_string, pattern, expected):
107 repo = backend.create_repo()
107 repo = backend.create_repo()
@@ -130,16 +130,16 b' def test_extract_issues(backend, text_st'
130
130
131
131
132 @pytest.mark.parametrize('text_string, pattern, link_format, expected_text', [
132 @pytest.mark.parametrize('text_string, pattern, link_format, expected_text', [
133 ('Fix #42', '(?:#)(?P<issue_id>\d+)', 'html',
133 ('Fix #42', r'(?:#)(?P<issue_id>\d+)', 'html',
134 'Fix <a class="tooltip issue-tracker-link" href="https://r.io/{repo}/i/42" title="Test Pattern">#42</a>'),
134 'Fix <a class="tooltip issue-tracker-link" href="https://r.io/{repo}/i/42" title="Test Pattern">#42</a>'),
135
135
136 ('Fix #42', '(?:#)(?P<issue_id>\d+)', 'markdown',
136 ('Fix #42', r'(?:#)(?P<issue_id>\d+)', 'markdown',
137 'Fix [#42](https://r.io/{repo}/i/42)'),
137 'Fix [#42](https://r.io/{repo}/i/42)'),
138
138
139 ('Fix #42', '(?:#)(?P<issue_id>\d+)', 'rst',
139 ('Fix #42', r'(?:#)(?P<issue_id>\d+)', 'rst',
140 'Fix `#42 <https://r.io/{repo}/i/42>`_'),
140 'Fix `#42 <https://r.io/{repo}/i/42>`_'),
141
141
142 ('Fix #42', '(?:#)?<issue_id>\d+)', 'html',
142 ('Fix #42', r'(?:#)?<issue_id>\d+)', 'html',
143 'Fix #42'), # Broken regex
143 'Fix #42'), # Broken regex
144 ])
144 ])
145 def test_process_patterns_repo(backend, text_string, pattern, expected_text, link_format):
145 def test_process_patterns_repo(backend, text_string, pattern, expected_text, link_format):
@@ -165,9 +165,9 b' def test_process_patterns_repo(backend, '
165
165
166
166
167 @pytest.mark.parametrize('text_string, pattern, expected_text', [
167 @pytest.mark.parametrize('text_string, pattern, expected_text', [
168 ('Fix #42', '(?:#)(?P<issue_id>\d+)',
168 ('Fix #42', r'(?:#)(?P<issue_id>\d+)',
169 'Fix <a class="tooltip issue-tracker-link" href="https://r.io/i/42" title="Test Pattern">#42</a>'),
169 'Fix <a class="tooltip issue-tracker-link" href="https://r.io/i/42" title="Test Pattern">#42</a>'),
170 ('Fix #42', '(?:#)?<issue_id>\d+)',
170 ('Fix #42', r'(?:#)?<issue_id>\d+)',
171 'Fix #42'), # Broken regex
171 'Fix #42'), # Broken regex
172 ])
172 ])
173 def test_process_patterns_no_repo(text_string, pattern, expected_text):
173 def test_process_patterns_no_repo(text_string, pattern, expected_text):
General Comments 0
You need to be logged in to leave comments. Login now