Replace None with empty string before creating td

This commit is contained in:
Mike Waldner
2011-08-07 19:19:54 -04:00
parent 33a83316df
commit a2b4e4c6ba
2 changed files with 26 additions and 2 deletions
+6 -2
View File
@@ -30,13 +30,17 @@ def export_set(dataset):
page.table.open()
if dataset.headers is not None:
new_header = [item if item is not None else '' for item in dataset.headers]
page.thead.open()
headers = markup.oneliner.th(dataset.headers)
headers = markup.oneliner.th(new_header)
page.tr(headers)
page.thead.close()
for row in dataset:
html_row = markup.oneliner.td(row)
new_row = [item if item is not None else '' for item in row]
html_row = markup.oneliner.td(new_row)
page.tr(html_row)
page.table.close()
+20
View File
@@ -224,6 +224,26 @@ class TablibTestCase(unittest.TestCase):
self.assertEqual(html, self.founders.html)
def test_html_export_none_value(self):
"""HTML export"""
html = markup.page()
html.table.open()
html.thead.open()
html.tr(markup.oneliner.th(['foo','', 'bar']))
html.thead.close()
html.tr(markup.oneliner.td(['foo','', 'bar']))
html.table.close()
html = str(html)
headers = ['foo', None, 'bar'];
d = tablib.Dataset(['foo', None, 'bar'], headers=headers)
self.assertEqual(html, d.html)
def test_unicode_append(self):
"""Passes in a single unicode charecter and exports."""