Exemplo n.º 1
0
class TestCSSRuleList(TestCase):
    def setUp(self):
        self.list = CSSRuleList()
        self.style = CSSStyleDeclaration()
        self.style.color = 'red'
        self.rule = CSSStyleRule('h1', self.style)

    def test_blank(self):
        self.assertEqual(self.list.cssText, '')

    def test_append(self):
        self.list.append(self.rule)
        self.assertEqual(self.list.cssText, 'h1 {color: red;}')

    def test_append2(self):
        self.list.append(self.rule)
        rule2 = CSSStyleRule('h2', CSSStyleDeclaration('background: black;'))
        self.list.append(rule2)
        css = self.list.cssText
        if sys.version_info < (3, 5):
            # python 3.4 can't keep order
            self.assertIn('h1 {color: red;}', css)
            self.assertIn('h2 {background: black;}', css)
        else:
            self.assertIn('h1 {color: red;}\nh2 {background: black;}', css)
Exemplo n.º 2
0
class TestCSSRuleList(TestCase):
    def setUp(self):
        self.list = CSSRuleList()
        self.style = CSSStyleDeclaration()
        self.style.color = 'red'
        self.rule = CSSStyleRule('h1', self.style)

    def test_blank(self):
        self.assertEqual(self.list.cssText, '')

    def test_append(self):
        self.list.append(self.rule)
        self.assertEqual(self.list.cssText, 'h1 {color: red;}')

    def test_append2(self):
        self.list.append(self.rule)
        rule2 = CSSStyleRule('h2', CSSStyleDeclaration('background: black;'))
        self.list.append(rule2)
        css = self.list.cssText
        self.assertIn('h1 {color: red;}\nh2 {background: black;}', css)
Exemplo n.º 3
0
 def setUp(self):
     self.list = CSSRuleList()
     self.style = CSSStyleDeclaration()
     self.style.color = 'red'
     self.rule = CSSStyleRule('h1', self.style)
Exemplo n.º 4
0
 def setUp(self):
     self.list = CSSRuleList()
     self.style = CSSStyleDeclaration()
     self.style.color = 'red'
     self.rule = CSSStyleRule('h1', self.style)