diff --git a/kallithea/tests/other/test_libs.py b/kallithea/tests/other/test_libs.py
--- a/kallithea/tests/other/test_libs.py
+++ b/kallithea/tests/other/test_libs.py
@@ -408,21 +408,58 @@ class TestLibs(TestController):
@parametrize('issue_pat,issue_server,issue_prefix,sample,expected', [
(r'#(\d+)', 'http://foo/{repo}/issue/{id}', '#',
- 'issue #123', 'issue #123'),
- (r'#(\d+)', 'http://foo/{repo}/issue/{id}', '#',
- 'issue#456', 'issue#456'),
+ 'issue #123 and issue#456',
+ """issue #123 and """
+ """issue#456"""),
+ (r'(?:\s*#)(\d+)', 'http://foo/{repo}/issue/{id}', '#',
+ 'issue #123 and issue#456',
+ """issue #123 and """
+ """issue#456"""),
+ (r'\bPR(\d+)', 'http://foo/{repo}/issue/{id}', '#',
+ 'issue PR123 and issuePR456',
+ """issue #123 and """
+ """issuePR456"""),
+ # following test case shows that \b does not work well in combination with '#': the expectations
+ # are reversed from what is actually happening.
+ (r'\b#(\d+)', 'http://foo/{repo}/issue/{id}', '#',
+ 'issue #123 and issue#456',
+ """issue #123 and """
+ """issue#456"""),
+ (r'[ \t]#(\d+)', 'http://foo/{repo}/issue/{id}', '#',
+ 'issue #123 and issue#456',
+ """issue #123 and """
+ """issue#456"""),
+ (r'(?:pullrequest|pull request|PR|pr) ?#?(\d+)', 'http://foo/{repo}/issue/{id}', 'PR#',
+ 'fixed with pullrequest #1, pull request#2, PR 3, pr4',
+ """fixed with PR#1, """
+ """PR#2, """
+ """PR#3, """
+ """PR#4"""),
(r'#(\d+)', 'http://foo/{repo}/issue/{id}', 'PR',
- 'interesting issue #123', 'interesting issue PR123'),
+ 'interesting issue #123',
+ """interesting issue PR123"""),
(r'BUG\d{5}', 'https://bar/{repo}/{id}', 'BUG',
- 'silly me, I did not parenthesize the {id}, BUG12345.', 'silly me, I did not parenthesize the {id}, BUG.'),
+ 'silly me, I did not parenthesize the {id}, BUG12345.',
+ """silly me, I did not parenthesize the {id}, BUG."""),
(r'BUG(\d{5})', 'https://bar/{repo}/', 'BUG',
- 'silly me, the URL does not contain {id}, BUG12345.', 'silly me, the URL does not contain {id}, BUG12345.'),
+ 'silly me, the URL does not contain {id}, BUG12345.',
+ """silly me, the URL does not contain {id}, BUG12345."""),
(r'(PR-\d+)', 'http://foo/{repo}/issue/{id}', '',
- 'interesting issue #123, err PR-56', 'interesting issue #123, err PR-56'),
+ 'interesting issue #123, err PR-56',
+ """interesting issue #123, err PR-56"""),
+ (r'#(\d+)', 'http://foo/{repo}/issue/{id}', '#',
+ "some 'standard' text with apostrophes",
+ """some 'standard' text with apostrophes"""),
(r'#(\d+)', 'http://foo/{repo}/issue/{id}', '#',
- "some 'standard' text with apostrophes", 'some 'standard' text with apostrophes'),
+ "some 'standard' issue #123",
+ """some 'standard' issue #123"""),
(r'#(\d+)', 'http://foo/{repo}/issue/{id}', '#',
- "some 'standard' issue #123", 'some 'standard' issue #123'),
+ 'an issue #123 with extra whitespace',
+ """an issue #123 with extra whitespace"""),
+ # Note: whitespace is squashed
+ (r'(?:\s*#)(\d+)', 'http://foo/{repo}/issue/{id}', '#',
+ 'an issue #123 with extra whitespace',
+ """an issue #123 with extra whitespace"""),
])
def test_urlify_issues(self, issue_pat, issue_server, issue_prefix, sample, expected):
from kallithea.lib.helpers import urlify_text