Example #1
0
 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()
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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')
Example #5
0
    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')
Example #6
0
    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')
Example #7
0
    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')
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
 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()
Example #11
0
 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()
Example #12
0
 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()