diff --git a/zephyr/tests.py b/zephyr/tests.py index 4cb1a63458..71e144ba42 100644 --- a/zephyr/tests.py +++ b/zephyr/tests.py @@ -1577,6 +1577,42 @@ int x = 3 self.common_bugdown_test('__foo__', '

__foo__

') self.common_bugdown_test('**foo**', '

foo

') + def test_linkify(self): + def replaced(payload, url): + return payload % ('URL'.replace('URL', url),) + + conversions = \ + [('http://www.google.com', "

%s

", 'http://www.google.com'), + ('https://www.google.com', "

%s

", 'https://www.google.com'), + (' some text https://www.google.com/', "

some text %s

", 'https://www.google.com/'), + ('with short example.com url', "

with short %s url

", 'example.com'), + ('t.co', "

%s

", 't.co'), + ('go to views.org please', "

go to %s please

", 'views.org'), + ('http://foo.com/blah_blah/', "

%s

", 'http://foo.com/blah_blah/'), + ('python class views.py is', "

python class views.py is

", ''), + ('with www www.humbughq.com/foo ok?', "

with www %s ok?

", 'www.humbughq.com/foo'), + ('allow questions like foo.com?', "

allow questions like %s?

", 'foo.com'), + ('"is.gd/foo/ "', "

\"%s \"

", 'is.gd/foo/'), + ('end of sentence https://t.co.', "

end of sentence %s.

", 'https://t.co'), + ('(Something like http://foo.com/blah_blah)', "

(Something like %s)

", 'http://foo.com/blah_blah'), + ('"is.gd/foo/"', "

\"%s\"

", 'is.gd/foo/'), + ('end with a quote www.google.com"', "

end with a quote %s\"

", 'www.google.com'), + + ('http://example.com/something?with,commas,in,url, but not at end', + "

%s but not at end

", 'http://example.com/something?with,commas,in,url,'), + (' some text https://www.google.com/baz_(match)?with=foo&bar=baz with extras', + "

some text %s with extras

", 'https://www.google.com/baz_(match)?with=foo&bar=baz'), + ('hash it http://foo.com/blah_(wikipedia)_blah#cite-1', + "

hash it %s

", 'http://foo.com/blah_(wikipedia)_blah#cite-1'),] + + for inline_url, reference, url in conversions: + try: + match = replaced(reference, url) + except TypeError: + match = reference + converted = convert(inline_url) + self.assertEqual(match, converted) + class Runner(DjangoTestSuiteRunner): option_list = ( optparse.make_option('--skip-generate',