comparison test/test_templating.py @ 4391:d5239335fae3

make URL detection a little smarter about brackets per issue2550657 (thanks Ezio Melotti)
author Richard Jones <richard@users.sourceforge.net>
date Mon, 12 Jul 2010 04:14:02 +0000
parents ce684080e968
children 66603a9051f9
comparison
equal deleted inserted replaced
4390:936bd9bf732d 4391:d5239335fae3
145 145
146 def test_url_replace(self): 146 def test_url_replace(self):
147 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '') 147 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '')
148 def t(s): return p.hyper_re.sub(p._hyper_repl, s) 148 def t(s): return p.hyper_re.sub(p._hyper_repl, s)
149 ae = self.assertEquals 149 ae = self.assertEquals
150 ae(t('http://roundup.net/'), '<a href="http://roundup.net/">http://roundup.net/</a>')
151 ae(t('&lt;HTTP://roundup.net/&gt;'), '&lt;<a href="HTTP://roundup.net/">HTTP://roundup.net/</a>&gt;')
152 ae(t('&lt;www.roundup.net&gt;'), '&lt;<a href="http://www.roundup.net">www.roundup.net</a>&gt;')
153 ae(t('item123123123123'), 'item123123123123') 150 ae(t('item123123123123'), 'item123123123123')
151 ae(t('http://roundup.net/'),
152 '<a href="http://roundup.net/">http://roundup.net/</a>')
153 ae(t('&lt;HTTP://roundup.net/&gt;'),
154 '&lt;<a href="HTTP://roundup.net/">HTTP://roundup.net/</a>&gt;')
155 ae(t('&lt;www.roundup.net&gt;'),
156 '&lt;<a href="http://www.roundup.net">www.roundup.net</a>&gt;')
157 ae(t('(www.roundup.net)'),
158 '(<a href="http://www.roundup.net">www.roundup.net</a>)')
159 ae(t('foo http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx bar'),
160 'foo <a href="http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx">'
161 'http://msdn.microsoft.com/en-us/library/ms741540(VS.85).aspx</a> bar')
162 ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language))'),
163 '(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">'
164 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>)')
165 ae(t('(e.g. http://en.wikipedia.org/wiki/Python_(programming_language)).'),
166 '(e.g. <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">'
167 'http://en.wikipedia.org/wiki/Python_(programming_language)</a>).')
154 168
155 ''' 169 '''
156 class HTMLPermissions: 170 class HTMLPermissions:
157 def is_edit_ok(self): 171 def is_edit_ok(self):
158 def is_view_ok(self): 172 def is_view_ok(self):

Roundup Issue Tracker: http://roundup-tracker.org/