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

# Source Code for Module cssutils.tests.test_cssproperties

     1  """Testcases for cssutils.css.cssproperties."""
     2  __version__ = '$Id: test_cssproperties.py 1116 2008-03-05 13:52:23Z cthedot $'
     3
     4  import xml.dom
     5  import basetest
     6  import cssutils.css
     7
     8 -class CSSPropertiesTestCase(basetest.BaseTestCase):
     9
    10 -    def test_cssvalues(self):
    11          "cssproperties cssvalues"
    12          # does actually return match object, so a very simplified test...
    13          match = cssutils.css.cssproperties.cssvalues
    14
    15          self.assertEquals(True, bool(match['color']('red')))
    16          self.assertEquals(False, bool(match['top']('red')))
    17
    18          self.assertEquals(True, bool(match['left']('0')))
    19          self.assertEquals(True, bool(match['left']('1px')))
    20          self.assertEquals(True, bool(match['left']('.1px')))
    21          self.assertEquals(True, bool(match['left']('-1px')))
    22          self.assertEquals(True, bool(match['left']('-.1px')))
    23          self.assertEquals(True, bool(match['left']('-0.1px')))
    24
    25 -    def test_toDOMname(self):
    26          "cssproperties _toDOMname(CSSname)"
    27          _toDOMname = cssutils.css.cssproperties._toDOMname
    28
    29          self.assertEquals('color', _toDOMname('color'))
    30          self.assertEquals('fontStyle', _toDOMname('font-style'))
    31          self.assertEquals('MozOpacity', _toDOMname('-moz-opacity'))
    32          self.assertEquals('UNKNOWN', _toDOMname('UNKNOWN'))
    33          self.assertEquals('AnUNKNOWN', _toDOMname('-anUNKNOWN'))
    34
    35 -    def test_toCSSname(self):
    36          "cssproperties _toCSSname(DOMname)"
    37          _toCSSname = cssutils.css.cssproperties._toCSSname
    38
    39          self.assertEquals('color', _toCSSname('color'))
    40          self.assertEquals('font-style', _toCSSname('fontStyle'))
    41          self.assertEquals('-moz-opacity', _toCSSname('MozOpacity'))
    42          self.assertEquals('UNKNOWN', _toCSSname('UNKNOWN'))
    43          self.assertEquals('-anUNKNOWN', _toCSSname('AnUNKNOWN'))
    44
    45 -    def test_CSS2Properties(self):
    46          "CSS2Properties"
    47          CSS2Properties = cssutils.css.cssproperties.CSS2Properties
    48          self.assertEquals(type(property()), type(CSS2Properties.color))
    49          self.assertEquals(len(cssutils.css.cssproperties.cssvalues),
    50                            len(CSS2Properties._properties))
    51
    52          c2 = CSS2Properties()
    53          # CSS2Properties has simplified implementation return always None
    54          self.assertEquals(None, c2.color)
    55          self.assertEquals(None, c2.__setattr__('color', 1))
    56          self.assertEquals(None, c2.__delattr__('color'))
    57          # only defined properties
    58          self.assertRaises(AttributeError, c2.__getattribute__, 'UNKNOWN')
    59
    60
    61  if __name__ == '__main__':
    62      import unittest
    63      unittest.main()
    64