Package cssutils :: Package tests :: Module test_csscomment
[hide private]
[frames] | no frames]

Source Code for Module cssutils.tests.test_csscomment

 1  # -*- coding: utf-8 -*- 
 2  """ 
 3  testcases for cssutils.css.CSSComment 
 4  """ 
 5  __author__ = '$LastChangedBy: cthedot $' 
 6  __date__ = '$LastChangedDate: 2007-11-01 22:39:38 +0100 (Do, 01 Nov 2007) $' 
 7  __version__ = '$LastChangedRevision: 620 $' 
 8   
 9  import xml 
10  import test_cssrule 
11  import cssutils.css 
12   
13 -class CSSCommentTestCase(test_cssrule.CSSRuleTestCase):
14
15 - def setUp(self):
16 super(CSSCommentTestCase, self).setUp() 17 self.r = cssutils.css.CSSComment() 18 self.rRO = cssutils.css.CSSComment(readonly=True) 19 self.r_type = cssutils.css.CSSComment.COMMENT 20 self.r_typeString = 'COMMENT'
21
22 - def test_init(self):
23 "CSSComment.type and init" 24 super(CSSCommentTestCase, self).test_init()
25
27 "CSSComment.cssText InvalidModificationErr" 28 self._test_InvalidModificationErr(u'/* comment */')
29
30 - def test_csstext(self):
31 "CSSComment.cssText" 32 tests = { 33 u'/*öäü߀ÖÄÜ*/': u'/*\xf6\xe4\xfc\xdf\u20ac\xd6\xc4\xdc*/', 34 35 u'/*x*/': None, 36 u'/* x */': None, 37 u'/*\t12\n*/': None, 38 u'/* /* */': None, 39 u'/* \\*/': None, 40 u'/*"*/': None, 41 u'''/*" 42 */''': None, 43 u'/** / ** //*/': None 44 } 45 self.do_equal_r(tests) # set cssText 46 tests.update({ 47 u'/*x': u'/*x*/', 48 u'\n /*': u'/**/', 49 }) 50 self.do_equal_p(tests) # parse 51 52 tests = { 53 u'/* */ */': xml.dom.InvalidModificationErr, 54 u' */ /* ': xml.dom.InvalidModificationErr, 55 u'*/': xml.dom.InvalidModificationErr, 56 u'@x /* x */': xml.dom.InvalidModificationErr 57 } 58 self.do_raise_r(tests) # set cssText
59 # no raising of error possible? 60 # self.do_raise_p(tests) # parse 61
62 - def test_reprANDstr(self):
63 "CSSComment.__repr__(), .__str__()" 64 text = '/* test */' 65 66 s = cssutils.css.CSSComment(cssText=text) 67 68 s2 = eval(repr(s)) 69 self.assert_(isinstance(s2, s.__class__)) 70 self.assert_(text == s2.cssText)
71 72 if __name__ == '__main__': 73 import unittest 74 unittest.main() 75