From 7c4723ff866051dc5875aae4eaf223ffe75120ff Mon Sep 17 00:00:00 2001 From: Juarez Rudsatz Date: Sun, 6 Feb 2022 21:22:26 -0300 Subject: [PATCH] pytest: test tohtml with css styles --- petl/test/io/test_html.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/petl/test/io/test_html.py b/petl/test/io/test_html.py index 56ae016d..127f5d09 100644 --- a/petl/test/io/test_html.py +++ b/petl/test/io/test_html.py @@ -86,3 +86,35 @@ def test_tohtml_caption(): u"\n" ) eq_(expect, actual) + + +def test_tohtml_with_style(): + + # exercise function + table = (('foo', 'bar'), + ('a', 1)) + + f = NamedTemporaryFile(delete=False) + tohtml(table, f.name, encoding='ascii', lineterminator='\n', + tr_style='text-align: right', td_styles='text-align: center') + + # check what it did + with io.open(f.name, mode='rt', encoding='ascii', newline='') as o: + actual = o.read() + expect = ( + u"\n" + u"\n" + u"\n" + u"\n" + u"\n" + u"\n" + u"\n" + u"\n" + u"\n" + u"\n" + u"\n" + u"\n" + u"\n" + u"
foobar
a1
\n" + ) + eq_(expect, actual)