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