1 """testcases for cssutils.css.CSSStyleRuleTestCase"""
2 __author__ = '$LastChangedBy: doerwalter $'
3 __date__ = '$LastChangedDate: 2007-08-02 22:58:23 +0200 (Do, 02 Aug 2007) $'
4 __version__ = '0.9.2b2, $LastChangedRevision: 160 $'
5
6
7 import xml.dom
8
9 import test_cssrule
10
11 import cssutils
12
13
15
21
22
33
34
38
39
41 "CSSStyleRule (incomplete)"
42 tests = {
43 u'a {': u'a {}',
44 u'a { font-family: "arial sans':
45 u'a {\n font-family: "arial sans"\n }',
46 }
47 self.do_equal_p(tests)
48
49
50 - def test_cssText(self):
51 "CSSStyleRule.cssText"
52 tests = {
53 u'''a\n{color: #000}''': 'a {\n color: #000\n }',
54 u'''a\n{color: #000000}''': 'a {\n color: #000000\n }',
55 u'''a\n{color: #abc}''': 'a {\n color: #abc\n }',
56 u'''a\n{color: #abcdef}''': 'a {\n color: #abcdef\n }',
57 u'''a\n{color: #00a}''': 'a {\n color: #00a\n }',
58 u'''a\n{color: #1a1a1a}''': 'a {\n color: #1a1a1a\n }',
59 u'''#id\n{}''': '#id {}',
60 u'''* {}''': None,
61 u'a {}': None,
62 u'b { a: 1; }': u'b {\n a: 1\n }',
63
64 u'c1 {/*1*/a:1;}': u'c1 {\n /*1*/\n a: 1\n }',
65 u'c2 {a:1;/*2*/}': u'c2 {\n a: 1;\n /*2*/\n }',
66 u'd1 {/*0*/}': u'd1 {\n /*0*/\n }',
67 u'd2 {/*0*//*1*/}': u'd2 {\n /*0*/\n /*1*/\n }'
68 }
69 self.do_equal_p(tests)
70 self.do_equal_r(tests)
71
72 tests = {
73 u'''a;''': xml.dom.SyntaxErr,
74 u'''a {{}''': xml.dom.SyntaxErr,
75 u'''a }''': xml.dom.SyntaxErr,
76 }
77 self.do_raise_p(tests)
78 tests.update({
79 u'''a {}x''': xml.dom.SyntaxErr,
80 u'''/*x*/''': xml.dom.SyntaxErr,
81 u'''a {''': xml.dom.SyntaxErr,
82 })
83 self.do_raise_r(tests)
84
85
101
102
104 "CSSStyleRule.selectorText"
105 r = cssutils.css.CSSStyleRule()
106
107 r.selectorText = u'a'
108 self.assertEqual(1, r.selectorList.length)
109 self.assertEqual(u'a', r.selectorText)
110
111 r.selectorText = u' b, h1 '
112 self.assertEqual(2, r.selectorList.length)
113 self.assertEqual(u'b, h1', r.selectorText)
114
115
124
125
126 if __name__ == '__main__':
127 import unittest
128 unittest.main()
129