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