Mercurial > p > roundup > code
diff test/test_templating.py @ 7864:b080cdb8b199
fix: document/fix wrapped HtmlProperty method.
The wrapped method was not documented in reference.txt.
It is now documented in reference.txt. The docstring documented that
it would not break up long words. Fixed by adding
break_long_words=False to prevent breaking string longer than the wrap
length. Wrapping was breaking the hyperlinking of long urls.
Added columns argument to set the wrap length (default 80 columns).
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 07 Apr 2024 15:27:18 -0400 |
| parents | 978285986b2c |
| children | 9bbc1d951677 |
line wrap: on
line diff
--- a/test/test_templating.py Sun Apr 07 15:21:00 2024 -0400 +++ b/test/test_templating.py Sun Apr 07 15:27:18 2024 -0400 @@ -450,7 +450,9 @@ ' Put in <html> to be escaped. Put in a' ' https://example.com/link as well. Let us see if' ' it will wrap properly.' ) - test_result = ('A long string that needs to be wrapped to 80' + + test_result_wrap = {} + test_result_wrap[80] = ('A long string that needs to be wrapped to 80' ' characters and no more. Put in a\n' 'link <a href="issue1">issue1</a>. Put in' ' <html> to be escaped. Put in a <a' @@ -458,10 +460,30 @@ ' rel="nofollow noopener">' 'https://example.com/link</a> as\n' 'well. Let us see if it will wrap properly.') + test_result_wrap[20] = ( + 'A long string that\n' + 'needs to be wrapped\n' + 'to 80 characters and\n' + 'no more. Put in a\nlink <a href="issue1">issue1</a>. Put in\n' + '<html> to be\n' + 'escaped. Put in a\n' + '<a href="https://example.com/link" rel="nofollow ' + 'noopener">https://example.com/link</a>\n' + 'as well. Let us see\n' + 'if it will wrap\n' + 'properly.') + test_result_wrap[100] = ( + 'A long string that needs to be wrapped to 80 characters and no more. Put in a link <a href="issue1">issue1</a>. Put in\n' + '<html> to be escaped. Put in a <a href="https://example.com/link" rel="nofollow noopener">https://example.com/link</a> as well. Let us see if it will wrap\n' + 'properly.') p = StringHTMLProperty(self.client, 'test', '1', None, 'test', test_string) - self.assertEqual(p.wrapped(), test_result) + + for i in [80, 20, 100]: + wrapped = p.wrapped(columns=i) + print(wrapped) + self.assertEqual(wrapped, test_result_wrap[i]) def test_string_plain_or_hyperlinked(self): ''' test that email obscures the email '''
