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

# Source Code for Module cssutils.tests.test_parse

     1  """
     2  tests for parsing which does not raise Exceptions normally
     3  """
     4  __author__ = '$LastChangedBy: doerwalter $'
     5  __date__ = '$LastChangedDate: 2007-08-09 21:41:10 +0200 (Do, 09 Aug 2007) $'
     6  __version__ = '0.9.2a1, $LastChangedRevision: 210 $'
     7
     8  import xml.dom
     9
    10  import basetest
    11
    12  import cssutils
    13
    14 -class CSSStyleSheetTestCase(basetest.BaseTestCase):
    15
    16 -    def setUp(self):
    17          # should be be disabled here??
    18          ##cssutils.log.raiseExceptions = False
    19          pass
    20
    21
    22 -    def test_invalidstring(self):
    23          "cssutils.parseString(INVALID_STRING)"
    24          validfromhere = '@import "x";'
    25          csss = (
    26              u'''@charset "ascii
    27                  ;''' + validfromhere,
    28              u'''@charset 'ascii
    29                  ;''' + validfromhere,
    30              u'''@import "x
    31                  ;''' + validfromhere,
    32              u'''@unknown "x
    33                  ;''' + validfromhere)
    34          for css in csss:
    35              s = cssutils.parseString(css)
    36              self.assertEqual(validfromhere, s.cssText)
    37
    38          css = u'''a { font-family: "Courier
    39                  ; }'''
    40          s = cssutils.parseString(css)
    41          self.assertEqual(u'a {}', s.cssText)
    42
    43
    44 -    def test_attributes(self):
    45          "cssutils.parseString(href, media)"
    46          s = cssutils.parseString("a{}", href="file:foo.css", media="screen, projection, tv")
    47          self.assertEqual(s.href, "file:foo.css")
    48          self.assertEqual(s.media, ["screen", "projection", "tv"])
    49
    50          s = cssutils.parseString("a{}", href="file:foo.css", media=["screen", "projection", "tv"])
    51          self.assertEqual(s.media, ["screen", "projection", "tv"])
    52
    53
    54 -    def tearDown(self):
    55          # needs to be reenabled here for other tests
    56          cssutils.log.raiseExceptions = True
    57
    58
    59  if __name__ == '__main__':
    60      import unittest
    61      unittest.main()
    62