def test_render_double(self): df = pd.DataFrame({"A": [0, 1]}) style = lambda x: pd.Series( ["color: red; border: 1px", "color: blue; border: 2px"], name=x.name) s = Styler(df, uuid='AB').apply(style) s.render()
def test_table_attributes(self): attributes = 'class="foo" data-bar' styler = Styler(self.df, table_attributes=attributes) result = styler.render() self.assertTrue('class="foo" data-bar' in result) result = self.df.style.set_table_attributes(attributes).render() self.assertTrue('class="foo" data-bar' in result)
def test_uuid(self): styler = Styler(self.df, uuid='abc123') result = styler.render() self.assertTrue('abc123' in result) styler = self.df.style result = styler.set_uuid('aaa') self.assertTrue(result is styler) self.assertEqual(result.uuid, 'aaa')
def test_caption(self): styler = Styler(self.df, caption='foo') result = styler.render() self.assertTrue(all(['caption' in result, 'foo' in result])) styler = self.df.style result = styler.set_caption('baz') self.assertTrue(styler is result) self.assertEqual(styler.caption, 'baz')
def test_table_styles(self): style = [{'selector': 'th', 'props': [('foo', 'bar')]}] styler = Styler(self.df, table_styles=style) result = ' '.join(styler.render().split()) self.assertTrue('th { foo: bar; }' in result) styler = self.df.style result = styler.set_table_styles(style) self.assertTrue(styler is result) self.assertEqual(styler.table_styles, style)
def test_render(self): df = pd.DataFrame({"A": [0, 1]}) style = lambda x: pd.Series(["color: red", "color: blue"], name=x.name) s = Styler(df, uuid='AB').apply(style).apply(style, axis=1) s.render()
def test_render_double(self): df = pd.DataFrame({"A": [0, 1]}) style = lambda x: pd.Series(["color: red; border: 1px", "color: blue; border: 2px"], name=x.name) s = Styler(df, uuid='AB').apply(style) s.render()