1 """Testcases for cssutils.css.property._Property."""
2 __author__ = '$LastChangedBy: cthedot $'
3 __date__ = '$LastChangedDate: 2007-08-26 13:31:10 +0200 (So, 26 Aug 2007) $'
4 __version__ = '$LastChangedRevision: 269 $'
5
6 import xml.dom
7 import basetest
8 import cssutils
9
11
14
28
30 "_Property.name"
31 p = cssutils.css.property._Property('top', '1px')
32 p.name = 'left'
33 self.assertEqual('left', p.name)
34
35 tests = {
36 u'top': None,
37 u' top': u'top',
38 u'top ': u'top',
39 u' top ': u'top',
40 u'/*x*/ top ': u'top',
41 u' top /*x*/': u'top',
42 u'/*x*/top/*x*/': u'top',
43 u'\\x': None,
44 u'a\\010': None,
45 u'a\\01': None
46 }
47 self.do_equal_r(tests, att='name')
48
49 tests = {
50 u'': xml.dom.SyntaxErr,
51 u' ': xml.dom.SyntaxErr,
52 u'"\n': xml.dom.SyntaxErr,
53 u'/*x*/': xml.dom.SyntaxErr,
54 u':': xml.dom.SyntaxErr,
55 u';': xml.dom.SyntaxErr,
56 u'top:': xml.dom.SyntaxErr,
57 u'top;': xml.dom.SyntaxErr,
58 }
59 self.do_raise_r(tests, att='_setName')
60
61
62
63
64
65
66
67
68
69
70
72 "_Property.cssValue"
73 pass
74
75
77 "_Property.priority"
78 p = cssutils.css.property._Property('top', '1px', '!important')
79
80 p.priority = ''
81 self.assertEqual('', p.priority)
82
83 p.priority = '!important'
84 self.assertEqual('!important', p.priority)
85
86 p.priority = None
87 self.assertEqual('', p.priority)
88
89 p.priority = '! important'
90 self.assertEqual('!important', p.priority)
91
92 tests = {
93 u' ': xml.dom.SyntaxErr,
94 u'"\n': xml.dom.SyntaxErr,
95 u'important': xml.dom.SyntaxErr,
96 u';': xml.dom.SyntaxErr,
97 u'!important !important': xml.dom.SyntaxErr
98 }
99 self.do_raise_r(tests, att='_setPriority')
100
102 "_Property.value (DEPRECATED)"
103 p = cssutils.css.property._Property('top', u'1px')
104 self.assertEqual('1px', p.value)
105 p.value = '2px'
106 self.assertEqual('2px', p.value)
107
108 tests = {
109 u'1px': None,
110 u' 2px': u'2px',
111 u'3px ': u'3px',
112 u' 4px ': u'4px',
113 u'5px 1px': u'5px 1px',
114 }
115 self.do_equal_r(tests, att='value')
116
117 tests = {
118
119 None: xml.dom.SyntaxErr,
120 u'': xml.dom.SyntaxErr,
121 u' ': xml.dom.SyntaxErr,
122 u'"\n': xml.dom.SyntaxErr,
123 u'/*x*/': xml.dom.SyntaxErr,
124
125 u':': xml.dom.SyntaxErr,
126 u';': xml.dom.SyntaxErr,
127 u'!important': xml.dom.SyntaxErr,
128 }
129 self.do_raise_r(tests, att='_setValue')
130
148
149
150 if __name__ == '__main__':
151 import unittest
152 unittest.main()
153