4 new revisions:

Revision: 9eaeb3696b58
Author:   Pekka Klärck
Date:     Tue Mar  6 12:33:07 2012
Log: test_htmlutils: Namespaces are one honking great idea -- let's do more...
http://code.google.com/p/robotframework/source/detail?r=9eaeb3696b58

Revision: 5c56f13911e8
Author:   Pekka Klärck
Date:     Tue Mar  6 23:54:55 2012
Log:      test_htmlutils: Also helper method are a honking good idea
http://code.google.com/p/robotframework/source/detail?r=5c56f13911e8

Revision: 8dc1573b6217
Author:   Pekka Klärck
Date:     Tue Mar  6 23:58:44 2012
Log:      Initial, and inactive, tests for possible feature creep
http://code.google.com/p/robotframework/source/detail?r=8dc1573b6217

Revision: b7298936c914
Author:   Pekka Klärck
Date:     Tue Mar  6 23:58:59 2012
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=b7298936c914

==============================================================================
Revision: 9eaeb3696b58
Author:   Pekka Klärck
Date:     Tue Mar  6 12:33:07 2012
Log: test_htmlutils: Namespaces are one honking great idea -- let's do more of those
http://code.google.com/p/robotframework/source/detail?r=9eaeb3696b58

Modified:
 /utest/utils/test_htmlutils.py

=======================================
--- /utest/utils/test_htmlutils.py      Fri Feb 17 04:18:48 2012
+++ /utest/utils/test_htmlutils.py      Tue Mar  6 12:33:07 2012
@@ -45,7 +45,7 @@
                 _test_escape_and_format(inp, exp)


-class TestLinks(unittest.TestCase):
+class TestUrlsToLinks(unittest.TestCase):

     def test_not_links(self):
         for nolink in ['http no link', 'http:/no', 'xx://no',
@@ -99,7 +99,7 @@
'<a href="ftp://&lt;&amp;&gt;/";>ftp://&lt;&amp;&gt;/</a>')


-class TestHtmlFormat(unittest.TestCase):
+class TestHtmlFormatBoldAndItalic(unittest.TestCase):

     def test_one_word_bold(self):
         for inp, exp in [('*bold*', '<b>bold</b>'),
@@ -225,6 +225,9 @@
                          ('*b _bi*_', '<b>b <i>bi</b></i>')]:
             assert_equals(html_format(inp), exp)

+
+class TestHtmlFormatTable(unittest.TestCase):
+
     def test_one_row_table(self):
         inp = '| one | two |'
         exp = _format_table([['one','two']])
@@ -379,6 +382,9 @@
                              ['2','<a href="ftp://two/";>ftp://two/</a>']])
         assert_equals(html_format(inp), exp)

+
+class TestHtmlFormatHr(unittest.TestCase):
+
     def test_hr_is_three_or_more_hyphens(self):
         for i in range(3, 10):
             hr = '-' * i
@@ -407,7 +413,7 @@
         assert_equals(html_format(inp), exp)


-class TestPreformattedBlock(unittest.TestCase):
+class TestHtmlFormatPreformatted(unittest.TestCase):

     def test_single_line_block(self):
         self._assert_preformatted('| some', 'some')

==============================================================================
Revision: 5c56f13911e8
Author:   Pekka Klärck
Date:     Tue Mar  6 23:54:55 2012
Log:      test_htmlutils: Also helper method are a honking good idea
http://code.google.com/p/robotframework/source/detail?r=5c56f13911e8

Modified:
 /utest/utils/test_htmlutils.py

=======================================
--- /utest/utils/test_htmlutils.py      Tue Mar  6 12:33:07 2012
+++ /utest/utils/test_htmlutils.py      Tue Mar  6 23:54:55 2012
@@ -1,6 +1,6 @@
 import unittest

-from robot.utils.asserts import *
+from robot.utils.asserts import assert_equals

from robot.utils.htmlutils import html_escape, html_format, html_attr_escape
 from robot.utils.htmlformatters import TableFormatter
@@ -8,7 +8,7 @@
 _format_table = TableFormatter().format


-def _test_escape_and_format(inp, exp_escape=None, exp_format=None):
+def assert_escape_and_format(inp, exp_escape=None, exp_format=None):
     if exp_escape is None:
         exp_escape = str(inp)
     if exp_format is None:
@@ -20,19 +20,26 @@
     assert_equals(format, exp_format,
'FORMAT:\n%r =!\n%r' % (format, exp_format), values=False)

+def assert_escape(inp, exp):
+    assert_equals(html_escape(inp), exp)
+
+def assert_format(inp, exp=None):
+    exp = exp if exp is not None else inp
+    assert_equals(html_format(inp), exp)
+

 class TestHtmlEscapeAndFormat(unittest.TestCase):

     def test_no_changes(self):
         for inp in ['', 'nothing to change']:
-            _test_escape_and_format(inp)
+            assert_escape_and_format(inp)

     def test_newlines_and_paragraphs(self):
         for inp in ['Text on first line.\nText on second line.',
                     '1 line\n2 line\n3 line\n4 line\n5 line\n',
                     'Para 1 line 1\nP1 L2\n\nP2 L1\nP2 L1\n\nP3 L1\nP3 L2',
                      'Multiple empty lines\n\n\n\n\nbetween these lines']:
-            _test_escape_and_format(inp, inp, inp.rstrip())
+            assert_escape_and_format(inp, inp, inp.rstrip())

     def test_entities(self):
         for char, entity in [('<','&lt;'), ('>','&gt;'), ('&','&amp;')]:
@@ -42,7 +49,7 @@
                               '-%s-%s-' % (entity, entity)),
                              ('"%s&%s"' % (char, char),
                               '"%s&amp;%s"' % (entity, entity))]:
-                _test_escape_and_format(inp, exp)
+                assert_escape_and_format(inp, exp)


 class TestUrlsToLinks(unittest.TestCase):
@@ -50,18 +57,18 @@
     def test_not_links(self):
         for nolink in ['http no link', 'http:/no', 'xx://no',
                        'tooolong10://no', 'http://', 'http:// no']:
-            _test_escape_and_format(nolink)
+            assert_escape_and_format(nolink)

     def test_simple_links(self):
for link in ['http://robot.fi', 'https://r.fi/', 'FTP://x.y.z/p/f.txt',
                      '123456://link', 'file:///c:/temp/xxx.yyy']:
             exp = '<a href="%s">%s</a>' % (link, link)
-            _test_escape_and_format(link, exp)
+            assert_escape_and_format(link, exp)
for end in [',', '.', ';', ':', '!', '?', '...', '!?!', ' hello' ]:
-                _test_escape_and_format(link+end, exp+end)
-                _test_escape_and_format('xxx '+link+end, 'xxx '+exp+end)
- for start, end in [ ('(',')'), ('[',']'), ('"','"'), ("'","'") ]:
-                _test_escape_and_format(start+link+end, start+exp+end)
+                assert_escape_and_format(link+end, exp+end)
+                assert_escape_and_format('xxx '+link+end, 'xxx '+exp+end)
+            for start, end in [('(',')'), ('[',']'), ('"','"'), ("'","'")]:
+                assert_escape_and_format(start+link+end, start+exp+end)

     def test_complex_links(self):
         for inp, exp in [
@@ -78,8 +85,8 @@
                 ('Hello http://one, ftp://kaksi/; "gopher://3.0";',
                  'Hello <a href="http://one";>http://one</a>, '
                  '<a href="ftp://kaksi/";>ftp://kaksi/</a>; '
-                 '"<a href="gopher://3.0";>gopher://3.0</a>"') ]:
-            _test_escape_and_format(inp, exp)
+                 '"<a href="gopher://3.0";>gopher://3.0</a>"')]:
+            assert_escape_and_format(inp, exp)

     def test_image_links(self):
         link = '(<a href="%s">%s</a>)'
@@ -88,14 +95,14 @@
             url = 'foo://bar/zap.%s' % ext
             uprl = url.upper()
             inp = '(%s)' % url
- _test_escape_and_format(inp, link % (url, url), img % (url, url))
-            _test_escape_and_format(inp.upper(), link % (uprl, uprl),
+ assert_escape_and_format(inp, link % (url, url), img % (url, url))
+            assert_escape_and_format(inp.upper(), link % (uprl, uprl),
                                     img % (uprl, uprl))

     def test_link_with_chars_needed_escaping(self):
-        assert_equals(html_escape('http://foo"bar'),
+        assert_escape('http://foo"bar',
'<a href="http://foo&quot;bar";>http://foo&quot;bar</a>')
-        assert_equals(html_escape('ftp://<&>/'),
+        assert_escape('ftp://<&>/',
'<a href="ftp://&lt;&amp;&gt;/";>ftp://&lt;&amp;&gt;/</a>')


@@ -112,7 +119,7 @@
                          ('***', '<b>*</b>'),
                          ('****', '<b>**</b>'),
                          ('*****', '<b>***</b>')]:
-            assert_equals(html_format(inp), exp, "'%s'" % inp)
+            assert_format(inp, exp)

     def test_multiple_word_bold(self):
         for inp, exp in [('*bold* *b* not bold *b3* not',
@@ -121,25 +128,23 @@
'not b <b>this is b</b> <b>more b words here</b>'),
                          ('*** not *b* ***',
                           '<b>*</b> not <b>b</b> <b>*</b>')]:
-            assert_equals(html_format(inp), exp, "'%s'" % inp)
+            assert_format(inp, exp)

     def test_bold_on_multiple_lines(self):
         inp = 'this is *bold*\nand *this*\nand *that*'
         exp = 'this is <b>bold</b>\nand <b>this</b>\nand <b>that</b>'
-        assert_equals(html_format(inp), exp)
-        inp2 = 'this *does not\nwork*'
-        assert_equals(html_format(inp2), inp2.replace('\n','\n'))
+        assert_format(inp, exp)
+        assert_format('this *does not\nwork*')

     def test_not_bolded_if_no_content(self):
-        assert_equals(html_format('**'), '**')
+        assert_format('**')

     def test_asterisk_in_the_middle_of_word_is_ignored(self):
         for inp, exp in [('aa*notbold*bbb', None),
                          ('*bold*still bold*', '<b>bold*still bold</b>'),
                          ('a*not*b c*still not*d', None),
('*b*b2* -*n*- *b3*', '<b>b*b2</b> -*n*- <b>b3</b>')]:
-            if exp is None: exp = inp
-            assert_equals(html_format(inp), exp)
+            assert_format(inp, exp)

     def test_asterisk_alone_does_not_start_bolding(self):
         for inp, exp in [('*', None),
@@ -152,8 +157,7 @@
                          ('*bold * not*', '<b>bold </b> not*'),
                          ('*bold * not*not* *b*',
                           '<b>bold </b> not*not* <b>b</b>')]:
-            if exp is None: exp = inp
-            assert_equals(html_format(inp), exp)
+            assert_format(inp, exp)

     def test_one_word_italic(self):
         for inp, exp in [('_italic_', '<i>italic</i>'),
@@ -163,29 +167,28 @@
                          ('_italic_ ', '<i>italic</i> '),
                          ('xx _italic_', 'xx <i>italic</i>'),
                          ('_italic_ xx', '<i>italic</i> xx')]:
-            assert_equals(repr(html_format(inp)), repr(exp), "'%s'" % inp)
+            assert_format(inp, exp)

     def test_multiple_word_italic(self):
         for inp, exp in [('_italic_ _i_ not italic _i3_ not',
'<i>italic</i> <i>i</i> not italic <i>i3</i> not'),
                          ('not i _this is i_ _more i words here_',
'not i <i>this is i</i> <i>more i words here</i>')]:
-            assert_equals(html_format(inp), exp, "'%s'" % inp)
+            assert_format(inp, exp)

     def test_not_italiced_if_no_content(self):
-        assert_equals(html_format('__'), '__')
+        assert_format('__')

     def test_not_italiced_many_underlines(self):
-        for text in ['___', '____', '_________', '__len__']:
-            assert_equals(html_format(text), text)
+        for inp in ['___', '____', '_________', '__len__']:
+            assert_format(inp)

     def test_underscore_in_the_middle_of_word_is_ignored(self):
         for inp, exp in [('aa_notitalic_bbb', None),
                          ('_ital_still ital_', '<i>ital_still ital</i>'),
                          ('a_not_b c_still not_d', None),
('_b_b2_ -_n_- _b3_', '<i>b_b2</i> -_n_- <i>b3</i>')]:
-            if exp is None: exp = inp
-            assert_equals(html_format(inp), exp)
+            assert_format(inp, exp)

     def test_underscore_alone_does_not_start_italicing(self):
         for inp, exp in [('_', None),
@@ -198,12 +201,11 @@
                          ('_italic _ not_', '<i>italic </i> not_'),
                          ('_italic _ not_not_ _b_',
                           '<i>italic </i> not_not_ <i>b</i>')]:
-            if exp is None: exp = inp
-            assert_equals(html_format(inp), exp)
+            assert_format(inp, exp)

     def test_bold_and_italic(self):
-        for inp, exp in [ ('*b* _i_', '<b>b</b> <i>i</i>') ]:
-            assert_equals(html_format(inp), exp)
+        for inp, exp in [('*b* _i_', '<b>b</b> <i>i</i>')]:
+            assert_format(inp, exp)

     def test_bold_and_italic_works_with_punctuation_marks(self):
         for bef, aft in [('(',''), ('"',''), ("'",''), ('(\'"(',''),
@@ -212,9 +214,7 @@
             for inp, exp in [('*bold*','<b>bold</b>'),
                              ('_ital_','<i>ital</i>'),
                              ('*b* _i_','<b>b</b> <i>i</i>')]:
-                inp = bef + inp + aft
-                exp = bef + exp + aft
-                assert_equals(html_format(inp), exp)
+                assert_format(bef + inp + aft, bef + exp + aft)

     def test_bold_italic(self):
         for inp, exp in [('_*bi*_', '<i><b>bi</b></i>'),
@@ -223,7 +223,7 @@
                          ('_*bi_ b*', '<i><b>bi</i> b</b>'),
                          ('_i *bi*_', '<i>i <b>bi</b></i>'),
                          ('*b _bi*_', '<b>b <i>bi</b></i>')]:
-            assert_equals(html_format(inp), exp)
+            assert_format(inp, exp)


 class TestHtmlFormatTable(unittest.TestCase):
@@ -231,19 +231,19 @@
     def test_one_row_table(self):
         inp = '| one | two |'
         exp = _format_table([['one','two']])
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_multi_row_table(self):
         inp = '| 1.1 | 1.2 | 1.3 |\n| 2.1 | 2.2 |\n| 3.1 | 3.2 | 3.3 |\n'
         exp = _format_table([['1.1','1.2','1.3'],
                              ['2.1','2.2'],
                              ['3.1','3.2','3.3']])
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_table_with_extra_spaces(self):
         inp = '  |   1.1   |  1.2   |  \n   | 2.1 | 2.2 |    '
         exp = _format_table([['1.1','1.2',],['2.1','2.2']])
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_table_with_one_space_empty_cells(self):
         inp = '''
@@ -262,12 +262,12 @@
                              ['','5.2',''],
                              ['','','6.3'],
                              ['','','']])
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_one_column_table(self):
         inp = '|  one column |\n| |\n  |  |  \n| 2 | col |\n|          |'
         exp = _format_table([['one column'],[''],[''],['2','col'],['']])
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_table_with_other_content_around(self):
         inp = '''before table
@@ -279,7 +279,7 @@
         exp = 'before table\n' \
             + _format_table([['in','table'],['still','in']]) \
             + '\n after table'
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_multiple_tables(self):
         inp = '''before tables
@@ -310,7 +310,7 @@
             + '\n' \
             + _format_table([['t','4'],['','']]) \
             + '\nafter'
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_ragged_table(self):
         inp = '''
@@ -322,7 +322,7 @@
             + _format_table([['1.1','1.2','1.3'],
                              ['2.1','',''],
                              ['3.1','3.2','']])
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_bold_in_table_cells(self):
         inp = '''
@@ -340,7 +340,7 @@
             + '\n' \
             + _format_table([['a','x <b>b</b> y','<b>b</b> <b>c</b>'],
                              ['*a','b*','']])
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_italic_in_table_cells(self):
         inp = '''
@@ -358,7 +358,7 @@
             + '\n' \
             +  _format_table([['a','x <i>b</i> y','<i>b</i> <i>c</i>'],
                               ['_a','b_','']])
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_bold_and_italic_in_table_cells(self):
         inp = '''
@@ -370,7 +370,7 @@
             + _format_table([['<b>a</b>','<b>b</b>','<b>c</b>'],
                              ['<i>b</i>','x','y'],
                              ['<i>c</i>','z','<b>b</b> <i>i</i>']])
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)

     def test_link_in_table_cell(self):
         inp = '''
@@ -380,7 +380,7 @@
         exp = '\n' \
             + _format_table([['1','<a href="http://one";>http://one</a>'],
                              ['2','<a href="ftp://two/";>ftp://two/</a>']])
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)


 class TestHtmlFormatHr(unittest.TestCase):
@@ -388,18 +388,18 @@
     def test_hr_is_three_or_more_hyphens(self):
         for i in range(3, 10):
             hr = '-' * i
-            assert_equals(html_format(hr), '<hr class="robotdoc">')
-            assert_equals(html_format(hr + '  '), '<hr class="robotdoc">')
+            assert_format(hr, '<hr class="robotdoc">')
+            assert_format(hr + '  ', '<hr class="robotdoc">')

     def test_hr_with_other_stuff_around(self):
         for inp, exp in [('---\n-', '<hr class="robotdoc">-'),
                          ('xx\n---\nxx', 'xx\n<hr class="robotdoc">xx'),
('xx\n\n------\n\nxx', 'xx\n\n<hr class="robotdoc">\nxx')]:
-            assert_equals(html_format(inp), exp)
+            assert_format(inp, exp)

     def test_not_hr(self):
         for inp in ['-', '--', ' ---', ' --- ', '...---...', '===']:
-            assert_equals(html_format(inp), inp)
+            assert_format(inp)

     def test_hr_before_and_after_table(self):
         inp = '''
@@ -410,7 +410,7 @@
         exp = '<hr class="robotdoc">' \
             + _format_table([['t','a','b','l','e']]) \
             + '<hr class="robotdoc">'
-        assert_equals(html_format(inp), exp)
+        assert_format(inp, exp)


 class TestHtmlFormatPreformatted(unittest.TestCase):
@@ -431,12 +431,11 @@
         self._assert_preformatted(' | some', 'some')

     def test_block_mixed_with_other_content(self):
- assert_equals(html_format('before block:\n| some\n| quote\nafter block'), - 'before block:\n<pre class="robotdoc">\nsome\nquote\n</pre>after block')
+        assert_format('before block:\n| some\n| quote\nafter block',
+ 'before block:\n<pre class="robotdoc">\nsome\nquote\n</pre>after block')

     def test_multiple_blocks(self):
- assert_equals(html_format('| some\n| quote\nbetween\n| other block\n\nafter'),
-                '''\
+ assert_format('| some\n| quote\nbetween\n| other block\n\nafter', '''\
 <pre class="robotdoc">
 some
 quote
@@ -445,12 +444,12 @@
 other block
 </pre>
 after''')
+
     def test_block_line_with_other_formatting(self):
         self._assert_preformatted('| _some_', '<i>some</i>')

-    def _assert_preformatted(self, input, expected):
-        expected = '<pre class="robotdoc">\n' + expected + '\n</pre>'
-        assert_equals(html_format(input), expected)
+    def _assert_preformatted(self, inp, exp):
+        assert_format(inp, '<pre class="robotdoc">\n' + exp + '\n</pre>')


 class TestFormatTable(unittest.TestCase):

==============================================================================
Revision: 8dc1573b6217
Author:   Pekka Klärck
Date:     Tue Mar  6 23:58:44 2012
Log:      Initial, and inactive, tests for possible feature creep
http://code.google.com/p/robotframework/source/detail?r=8dc1573b6217

Modified:
 /utest/utils/test_htmlutils.py

=======================================
--- /utest/utils/test_htmlutils.py      Tue Mar  6 23:54:55 2012
+++ /utest/utils/test_htmlutils.py      Tue Mar  6 23:58:44 2012
@@ -226,6 +226,23 @@
             assert_format(inp, exp)


+class TestHtmlFormatCustomLinks(unittest.TestCase):
+
+    def _test_text_with_text(self):
+        assert_format('[link.html|title]', '<a href="link.html">title</a>')
+
+    def _test_text_with_image(self):
+        assert_format('[link|img.png]',
+ '<a href="link"><img src="img.png" title="link"></a>')
+
+    def _test_image_with_text(self):
+ assert_format('[img.png|title]', '<img src="img.png" title="title">')
+
+    def _test_image_with_image(self):
+        assert_format('[x.png|thumb.png]',
+ '<a href="x.png"><img src="thumb.png" title="x.png"></a>')
+
+
 class TestHtmlFormatTable(unittest.TestCase):

     def test_one_row_table(self):

==============================================================================
Revision: b7298936c914
Author:   Pekka Klärck
Date:     Tue Mar  6 23:58:59 2012
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=b7298936c914


Reply via email to