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

# Source Code for Module cssutils.tests.test_parse

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