Author: pekka.klarck
Date: Sun Apr 5 06:46:03 2009
New Revision: 1670
Modified:
trunk/src/robot/utils/htmlwriter.py
trunk/utest/utils/test_htmlwriter.py
Log:
'is not None' check removed in previous commit was there for a reason.
Added a unit test to check it -- now only one unrelated acceptance test
failed because if.
Modified: trunk/src/robot/utils/htmlwriter.py
==============================================================================
--- trunk/src/robot/utils/htmlwriter.py (original)
+++ trunk/src/robot/utils/htmlwriter.py Sun Apr 5 06:46:03 2009
@@ -22,8 +22,8 @@
def __init__(self, output):
"""'output' is an open file object.
- Given 'output' must have been opened with 'wb' to be able to write
into
- it with UTF-8 encoding.
+ Given 'output' must have been opened with 'wb' to be able to
+ write into it with UTF-8 encoding.
'self.output.name' is later used by serializers
"""
@@ -36,7 +36,8 @@
self._start(name, attrs, close=True, newline=newline)
def content(self, content=None, escape=True):
- if content:
+ """Given content doesn't need to be a string"""
+ if content is not None:
if escape:
content = self._escape_content(content)
self._write(content)
Modified: trunk/utest/utils/test_htmlwriter.py
==============================================================================
--- trunk/utest/utils/test_htmlwriter.py (original)
+++ trunk/utest/utils/test_htmlwriter.py Sun Apr 5 06:46:03 2009
@@ -82,12 +82,12 @@
def test_content_with_non_ascii_data(self):
self.writer.start('robot', newline=False)
- self.writer.content(u'Circle is 360\u00B0 ')
- self.writer.content(u'Hyv\u00E4\u00E4 \u00FC\u00F6t\u00E4')
+ self.writer.content(u'Circle is 360\u00B0. ')
+ self.writer.content(u'Hyv\u00E4\u00E4 \u00FC\u00F6t\u00E4!')
self.writer.end('robot', newline=False)
- expected = u'<robot>Circle is 360\u00B0 Hyv\u00E4\u00E4
\u00FC\u00F6t\u00E4</robot>'
- self._verify(expected)
-
+ expected = u'Circle is 360\u00B0. Hyv\u00E4\u00E4
\u00FC\u00F6t\u00E4!'
+ self._verify('<robot>%s</robot>' % expected)
+
def test_multiple_content(self):
self.writer.start('robot')
self.writer.content('Hello world!')
@@ -104,6 +104,12 @@
self.writer.content(None)
self._verify('<robot>\n')
+ def test_content_with_non_strings(self):
+ for i in range(10):
+ self.writer.content(i)
+ self.writer.content(False)
+ self._verify('0123456789False')
+
def test_close_empty(self):
self.writer.end('suite', False)
self._verify('</suite>')