Ejemplo n.º 1
0
class CSSPageRuleTestCase(unittest.TestCase):

    def setUp(self):
        self.s = StyleDeclaration()
        self.s.setProperty('color', 'red')

    def test_emptyInit(self):
        p = PageRule()
        self.assertEqual(cssrule.CSSRule.PAGE_RULE, p.type)
        self.assertEqual(u'', p.cssText)

    def test_noSelector(self):
        p = PageRule()
        p.style = self.s
        self.assertEqual(u'@page {\n    color: red;\n    }', p.cssText)

    def test_fullInit(self):
        p = PageRule(':left', self.s)
        self.assertEqual(u'@page :left {\n    color: red;\n    }', p.cssText)

    def test_fullSet(self):
        p = PageRule()
        p.selectorText = ' :first,:left      ,   :right '
        p.style = self.s
        self.assertEqual(u'@page :first, :left, :right {\n    color: red;\n    }', p.cssText)

    def test_readonly(self):
        p = PageRule(':left', self.s, readonly=True)
        self.assertRaises(xml.dom.NoModificationAllowedErr, p._setSelectorText, u':left')
        p = PageRule(':left', self.s, readonly=True)
        self.assertRaises(xml.dom.NoModificationAllowedErr, p._setStyle, self.s)
Ejemplo n.º 2
0
class CSSFontFaceRuleTestCase(unittest.TestCase):

    def setUp(self):
        self.s = StyleDeclaration()
        self.s.setProperty('color', 'red')

    def test_emptyInit(self):
        f = FontFaceRule()
        self.assertEqual(cssrule.CSSRule.FONT_FACE_RULE, f.type)
        self.assertEqual(u'', f.cssText)

    def test_fullInit(self):
        f = FontFaceRule(self.s)
        self.assertEqual(u'@font-face {\n    color: red;\n    }', f.cssText)

    def test_readonly(self):
        pass
Ejemplo n.º 3
0
 def setUp(self):
     self.s = StyleDeclaration()
     self.s.setProperty('color', 'red')