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

# Source Code for Module cssutils.tests.test_csscomment

     1  # -*- coding: iso-8859-1 -*-
     2  """
     3  testcases for cssutils.css.CSSComment
     4  """
     5  __author__ = '$LastChangedBy: cthedot $'
     6  __date__ = '$LastChangedDate: 2007-08-20 22:09:16 +0200 (Mo, 20 Aug 2007) $'
     7  __version__ = '$LastChangedRevision: 258 $'
     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
    26 -    def test_InvalidModificationErr(self):
    27          "CSSComment.cssText InvalidModificationErr"
    28          self._test_InvalidModificationErr(u'/* comment */')
    29
    30 -    def test_csstext(self):
    31          "CSSComment.cssText"
    32          tests = {
    33              u'/*öäüß€ÖÄÜ*/': None,
    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.SyntaxErr,
    54              u'  */ /* ': xml.dom.SyntaxErr
    55              }
    56          self.do_raise_p(tests) # parse
    57          tests.update({
    58              u'*/': xml.dom.InvalidModificationErr,
    59              u'@x /* x */': xml.dom.InvalidModificationErr
    60              })
    61          self.do_raise_r(tests) # set cssText
    62
    63 -    def test_reprANDstr(self):
    64          "CSSComment.__repr__(), .__str__()"
    65          text = '/* test */'
    66
    67          s = cssutils.css.CSSComment(cssText=text)
    68
    69          s2 = eval(repr(s))
    70          self.assert_(isinstance(s2, s.__class__))
    71          self.assert_(text == s2.cssText)
    72
    73  if __name__ == '__main__':
    74      import unittest
    75      unittest.main()
    76