Skip to content

Commit f187a3a

Browse files
author
y-p
committed
TST: df.to_html() should respect col_space argument
1 parent 03a31cc commit f187a3a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/test_format.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,23 @@ def test_to_string_with_col_space(self):
189189
c30=len(df.to_string(col_space=30).split("\n")[1])
190190
self.assertTrue( c10 < c20 < c30 )
191191

192+
def test_to_html_with_col_space(self):
193+
def check_with_width(df,col_space):
194+
import re
195+
# check that col_space affects HTML generation
196+
# and be very brittle about it.
197+
html = df.to_html(col_space=col_space)
198+
hdrs = [x for x in html.split("\n") if re.search("<th[>\s]",x)]
199+
self.assertTrue(len(hdrs) > 0 )
200+
for h in hdrs:
201+
self.assertTrue("min-width" in h )
202+
self.assertTrue(str(col_space) in h )
203+
204+
df = DataFrame(np.random.random(size=(1,3)))
205+
206+
check_with_width(df,30)
207+
check_with_width(df,50)
208+
192209
def test_to_html_unicode(self):
193210
# it works!
194211
df = DataFrame({u'\u03c3' : np.arange(10.)})

0 commit comments

Comments
 (0)