Ignore:
Timestamp:
18 Mar 2011, 17:50:22 (14 years ago)
Author:
uli
Message:

Add tests for ReST2HTML to check for unicode-compliance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_helpers.py

    r5739 r5875  
     1# -*- coding: utf-8 -*-
     2
    13##
    24## test_helpers.py
     
    133135        return
    134136
     137class ReST2HTMLTestCase(unittest.TestCase):
    135138
     139    def setUp(self):
     140        self.expected = u'<div class="document">\n\n\n<p>Some '
     141        self.expected += u'test with \xfcmlaut</p>\n</div>'
     142        return
     143   
     144    def test_ascii_umlauts(self):
     145        # Make sure we convert umlauts correctly to unicode.
     146        source = 'Some test with ümlaut'
     147        result = helpers.ReST2HTML(source)
     148        self.assertEqual(result, self.expected)
     149
     150    def test_unicode_umlauts(self):
     151        # Make sure we convert umlauts correctly to unicode.
     152        source = u'Some test with ümlaut'
     153        result = helpers.ReST2HTML(source)
     154        self.assertEqual(result, self.expected)
     155
     156    def test_unicode_output_from_ascii(self):
     157        source = 'Some test with ümlaut'
     158        self.assertTrue(isinstance(helpers.ReST2HTML(source), unicode))
     159
     160    def test_unicode_output_from_unicode(self):
     161        source = u'Some test with ümlaut'
     162        self.assertTrue(isinstance(helpers.ReST2HTML(source), unicode))
     163
     164       
    136165class FactoryBaseTestCase(unittest.TestCase):
    137166
     
    148177    # Register local test cases...
    149178    for testcase in [
     179        ReST2HTMLTestCase,
    150180        FactoryBaseTestCase,
    151181        CopyFileSystemTreeTestCase,
Note: See TracChangeset for help on using the changeset viewer.