Mercurial > p > roundup > code
comparison test/test_templating.py @ 6551:f1f8d75edd97
Add variations on test for _hyper_url functons
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 11 Dec 2021 17:43:25 -0500 |
| parents | e29d5f4e0af4 |
| children | 21c7c2041a4b |
comparison
equal
deleted
inserted
replaced
| 6549:5ce92594cb27 | 6551:f1f8d75edd97 |
|---|---|
| 420 for g in groups: | 420 for g in groups: |
| 421 self.assertEqual(d[g], groups[g], '%s %r != %r in %r'%(g, d[g], | 421 self.assertEqual(d[g], groups[g], '%s %r != %r in %r'%(g, d[g], |
| 422 groups[g], s)) | 422 groups[g], s)) |
| 423 | 423 |
| 424 #t('123.321.123.321', 'url') | 424 #t('123.321.123.321', 'url') |
| 425 t('https://example.com/demo/issue8#24MRV9BZYx:V:1B~sssssssssssssss~4~4', url="https://example.com/demo/issue8#24MRV9BZYx:V:1B~sssssssssssssss~4~4") | |
| 425 t('http://localhost/', url='http://localhost/') | 426 t('http://localhost/', url='http://localhost/') |
| 426 t('http://roundup.net/', url='http://roundup.net/') | 427 t('http://roundup.net/', url='http://roundup.net/') |
| 427 t('http://richard@localhost/', url='http://richard@localhost/') | 428 t('http://richard@localhost/', url='http://richard@localhost/') |
| 428 t('http://richard:sekrit@localhost/', | 429 t('http://richard:sekrit@localhost/', |
| 429 url='http://richard:sekrit@localhost/') | 430 url='http://richard:sekrit@localhost/') |
| 437 t('www.foo.net', url='www.foo.net') | 438 t('www.foo.net', url='www.foo.net') |
| 438 t('richard@com.example', email='richard@com.example') | 439 t('richard@com.example', email='richard@com.example') |
| 439 t('r@a.com', email='r@a.com') | 440 t('r@a.com', email='r@a.com') |
| 440 t('i1', **{'class':'i', 'id':'1'}) | 441 t('i1', **{'class':'i', 'id':'1'}) |
| 441 t('item123', **{'class':'item', 'id':'123'}) | 442 t('item123', **{'class':'item', 'id':'123'}) |
| 443 t('item 123', **{'class':'item', 'id':'123'}) | |
| 442 t('www.user:pass@host.net', email='pass@host.net') | 444 t('www.user:pass@host.net', email='pass@host.net') |
| 443 t('user:pass@www.host.net', url='user:pass@www.host.net') | 445 t('user:pass@www.host.net', url='user:pass@www.host.net') |
| 444 t('123.35', nothing=True) | 446 t('123.35', nothing=True) |
| 445 t('-.3535', nothing=True) | 447 t('-.3535', nothing=True) |
| 446 | 448 |
| 447 def test_url_replace(self): | 449 def test_url_replace(self): |
| 448 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '') | 450 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', '') |
| 449 def t(s): return p.hyper_re.sub(p._hyper_repl, s) | 451 def t(s): return p.hyper_re.sub(p._hyper_repl, s) |
| 450 ae = self.assertEqual | 452 ae = self.assertEqual |
| 453 ae(t('foo https://example.com/demo/issue8#24MRV9BZYx:V:1B~sssssssssssssss~4~4 bar'), | |
| 454 'foo <a href="https://example.com/demo/issue8#24MRV9BZYx:V:1B~sssssssssssssss~4~4" rel="nofollow noopener">' | |
| 455 'https://example.com/demo/issue8#24MRV9BZYx:V:1B~sssssssssssssss~4~4</a> bar') | |
| 451 ae(t('item123123123123'), 'item123123123123') | 456 ae(t('item123123123123'), 'item123123123123') |
| 452 ae(t('http://roundup.net/'), | 457 ae(t('http://roundup.net/'), |
| 453 '<a href="http://roundup.net/" rel="nofollow noopener">http://roundup.net/</a>') | 458 '<a href="http://roundup.net/" rel="nofollow noopener">http://roundup.net/</a>') |
| 454 ae(t('<HTTP://roundup.net/>'), | 459 ae(t('<HTTP://roundup.net/>'), |
| 455 '<<a href="HTTP://roundup.net/" rel="nofollow noopener">HTTP://roundup.net/</a>>') | 460 '<<a href="HTTP://roundup.net/" rel="nofollow noopener">HTTP://roundup.net/</a>>') |
| 476 'http://en.wikipedia.org/wiki/Python_(programming_language</a>>)).') | 481 'http://en.wikipedia.org/wiki/Python_(programming_language</a>>)).') |
| 477 for c in '.,;:!': | 482 for c in '.,;:!': |
| 478 # trailing punctuation is not included | 483 # trailing punctuation is not included |
| 479 ae(t('http://roundup.net/%c ' % c), | 484 ae(t('http://roundup.net/%c ' % c), |
| 480 '<a href="http://roundup.net/" rel="nofollow noopener">http://roundup.net/</a>%c ' % c) | 485 '<a href="http://roundup.net/" rel="nofollow noopener">http://roundup.net/</a>%c ' % c) |
| 486 # trailing punctuation is not included without trailing space | |
| 487 ae(t('http://roundup.net/%c' % c), | |
| 488 '<a href="http://roundup.net/" rel="nofollow noopener">http://roundup.net/</a>%c' % c) | |
| 481 # but it's included if it's part of the URL | 489 # but it's included if it's part of the URL |
| 482 ae(t('http://roundup.net/%c/' % c), | 490 ae(t('http://roundup.net/%c/' % c), |
| 483 '<a href="http://roundup.net/%c/" rel="nofollow noopener">http://roundup.net/%c/</a>' % (c, c)) | 491 '<a href="http://roundup.net/%c/" rel="nofollow noopener">http://roundup.net/%c/</a>' % (c, c)) |
| 492 # including with a non / terminated path | |
| 493 ae(t('http://roundup.net/test%c ' % c), | |
| 494 '<a href="http://roundup.net/test" rel="nofollow noopener">http://roundup.net/test</a>%c ' % c) | |
| 495 # but it's included if it's part of the URL path | |
| 496 ae(t('http://roundup.net/%ctest' % c), | |
| 497 '<a href="http://roundup.net/%ctest" rel="nofollow noopener">http://roundup.net/%ctest</a>' % (c, c)) | |
| 498 | |
| 484 | 499 |
| 485 def test_input_html4(self): | 500 def test_input_html4(self): |
| 486 # boolean attributes are just the attribute name | 501 # boolean attributes are just the attribute name |
| 487 # indicate with attr=None or attr="attr" | 502 # indicate with attr=None or attr="attr" |
| 488 # e.g. disabled | 503 # e.g. disabled |
