1 """Testcases for cssutils.css.property._Property."""
2 __author__ = '$LastChangedBy: doerwalter $'
3 __date__ = '$LastChangedDate: 2007-08-02 22:58:23 +0200 (Do, 02 Aug 2007) $'
4 __version__ = '0.9.2a2, $LastChangedRevision: 160 $'
5
6 import xml.dom
7
8 import basetest
9
10 import cssutils
11
12
14
17
31
32
34 "_Property.name"
35 p = cssutils.css.property._Property('top', '1px')
36 p.name = 'left'
37 self.assertEqual('left', p.name)
38
39 tests = {
40 u'top': None,
41 u' top': u'top',
42 u'top ': u'top',
43 u' top ': u'top',
44 u'/*x*/ top ': u'top',
45 u' top /*x*/': u'top',
46 u'/*x*/top/*x*/': u'top',
47 u'\\x': None,
48 u'a\\010': None,
49 u'a\\01': None
50 }
51 self.do_equal_r(tests, att='name')
52
53 tests = {
54 u'': xml.dom.SyntaxErr,
55 u' ': xml.dom.SyntaxErr,
56 u'"\n': xml.dom.SyntaxErr,
57 u'/*x*/': xml.dom.SyntaxErr,
58 u':': xml.dom.SyntaxErr,
59 u';': xml.dom.SyntaxErr,
60 u'top:': xml.dom.SyntaxErr,
61 u'top;': xml.dom.SyntaxErr,
62 }
63 self.do_raise_r(tests, att='_setName')
64
65
75
76
78 "_Property.cssValue"
79 pass
80
81
82
84 "_Property.priority"
85 p = cssutils.css.property._Property('top', '1px', '!important')
86
87 p.priority = ''
88 self.assertEqual('', p.priority)
89
90 p.priority = '!important'
91 self.assertEqual('!important', p.priority)
92
93 p.priority = None
94 self.assertEqual('', p.priority)
95
96 p.priority = '! important'
97 self.assertEqual('!important', p.priority)
98
99
100 tests = {
101 u' ': xml.dom.SyntaxErr,
102 u'"\n': xml.dom.SyntaxErr,
103 u'important': xml.dom.SyntaxErr,
104 u';': xml.dom.SyntaxErr,
105 u'!important !important': xml.dom.SyntaxErr
106 }
107 self.do_raise_r(tests, att='_setPriority')
108
109
111 "_Property.value (DEPRECATED)"
112
113 p = cssutils.css.property._Property('top', u'1px')
114 self.assertEqual('1px', p.value)
115 p.value = '2px'
116 self.assertEqual('2px', p.value)
117
118 tests = {
119 u'1px': None,
120 u' 2px': u'2px',
121 u'3px ': u'3px',
122 u' 4px ': u'4px',
123 u'5px 1px': u'5px 1px',
124 }
125 self.do_equal_r(tests, att='value')
126
127 tests = {
128
129 None: xml.dom.SyntaxErr,
130 u'': xml.dom.SyntaxErr,
131 u' ': xml.dom.SyntaxErr,
132 u'"\n': xml.dom.SyntaxErr,
133 u'/*x*/': xml.dom.SyntaxErr,
134
135 u':': xml.dom.SyntaxErr,
136 u';': xml.dom.SyntaxErr,
137 u'!important': xml.dom.SyntaxErr,
138 }
139 self.do_raise_r(tests, att='_setValue')
140
141
142 if __name__ == '__main__':
143 import unittest
144 unittest.main()
145