[CMF-checkins] CVS: Products/CMFDefault/tests - test_utils.py:1.13

Yvo Schubbe y.2004_ at wcm-solutions.de
Sun Oct 17 15:37:30 EDT 2004


Update of /cvs-repository/Products/CMFDefault/tests
In directory cvs.zope.org:/tmp/cvs-serv30361/CMFDefault/tests

Modified Files:
	test_utils.py 
Log Message:
- added 'toUnicode' function (http://collector.zope.org/CMF/261, part 1)


=== Products/CMFDefault/tests/test_utils.py 1.12 => 1.13 ===
--- Products/CMFDefault/tests/test_utils.py:1.12	Mon Apr 26 08:14:18 2004
+++ Products/CMFDefault/tests/test_utils.py	Sun Oct 17 15:37:00 2004
@@ -8,14 +8,6 @@
 from Products.CMFCore.tests.base.content import SIMPLE_STRUCTUREDTEXT
 from Products.CMFCore.tests.base.content import SIMPLE_XHTML
 from Products.CMFCore.tests.base.content import STX_WITH_HTML
-from Products.CMFDefault.utils import bodyfinder
-from Products.CMFDefault.utils import comma_split
-from Products.CMFDefault.utils import html_headcheck
-from Products.CMFDefault.utils import html_marshal
-from Products.CMFDefault.utils import parseHeadersBody
-from Products.CMFDefault.utils import scrubHTML
-from Products.CMFDefault.utils import seq_strip
-from Products.CMFDefault.utils import tuplize
 
 
 class DefaultUtilsTests(TestCase):
@@ -32,6 +24,8 @@
 '''
 
     def test_NoBody( self ):
+        from Products.CMFDefault.utils import parseHeadersBody
+
         headers, body = parseHeadersBody( '%s\n\n' % self.COMMON_HEADERS )
         assert( len( headers ) == 2, '%d!' % len( headers ) )
         assert( 'Author' in headers.keys() )
@@ -40,6 +34,8 @@
         assert( len( body ) == 0, '%d!' % len( body ) )
 
     def test_Continuation( self ):
+        from Products.CMFDefault.utils import parseHeadersBody
+
         headers, body = parseHeadersBody( '%s\n%s\n\n'
                                         % ( self.COMMON_HEADERS
                                           , self.MULTILINE_DESCRIPTION
@@ -52,6 +48,8 @@
         assert( len( body ) == 0, '%d!' % len( body ) )
 
     def test_Body( self ):
+        from Products.CMFDefault.utils import parseHeadersBody
+
         headers, body = parseHeadersBody( '%s\n\n%s'
                                         % ( self.COMMON_HEADERS
                                           , self.TEST_BODY
@@ -61,6 +59,8 @@
         assert( body == self.TEST_BODY )
 
     def test_Preload( self ):
+        from Products.CMFDefault.utils import parseHeadersBody
+
         preloaded = { 'Author' : 'xxx', 'text_format' : 'structured_text' }
         headers, body = parseHeadersBody( '%s\n%s\n\n%s'
                                         % ( self.COMMON_HEADERS
@@ -74,6 +74,8 @@
         assert( preloaded[ 'text_format' ] == headers[ 'text_format' ] )
 
     def test_scrubHTML(self):
+        from Products.CMFDefault.utils import scrubHTML
+
         self.assertEqual( scrubHTML('<a href="foo.html">bar</a>'),
                           '<a href="foo.html">bar</a>' )
         self.assertEqual( scrubHTML('<b>bar</b>'),
@@ -94,6 +96,8 @@
                           '<meta name="title" content="" /><meta />' )
 
     def test_bodyfinder(self):
+        from Products.CMFDefault.utils import bodyfinder
+
         self.assertEqual( bodyfinder(FAUX_HTML_LEADING_TEXT),
                           '\n  <h1>Not a lot here</h1>\n ' )
         self.assertEqual( bodyfinder(SIMPLE_HTML),
@@ -106,6 +110,8 @@
                           '<p>Hello world, I am Bruce.</p>' )
 
     def test_html_headcheck(self):
+        from Products.CMFDefault.utils import html_headcheck
+
         self.assertEqual( html_headcheck(FAUX_HTML_LEADING_TEXT), 0 )
         self.assertEqual( html_headcheck(SIMPLE_HTML), 1 )
         self.assertEqual( html_headcheck(SIMPLE_STRUCTUREDTEXT), 0 )
@@ -113,6 +119,8 @@
         self.assertEqual( html_headcheck(STX_WITH_HTML), 0 )
 
     def test_tuplize(self):
+        from Products.CMFDefault.utils import comma_split
+        from Products.CMFDefault.utils import tuplize
         wanted = ('one','two','three')
 
         self.assertEqual( tuplize('string', 'one two three'), wanted )
@@ -123,15 +131,28 @@
         self.assertEqual( tuplize('tuple', ('one','two','three')), wanted )
 
     def test_seq_strip(self):
+        from Products.CMFDefault.utils import seq_strip
+
         self.assertEqual( seq_strip(['one ', ' two', ' three ']),
                           ['one','two','three'] )
         self.assertEqual( seq_strip(('one ', ' two', ' three ')),
                           ('one','two','three') )
 
     def test_html_marshal(self):
+        from Products.CMFDefault.utils import html_marshal
+
         self.assertEqual( html_marshal(foo=1), ( ('foo:int', '1'), ) )
         self.assertEqual( html_marshal(foo=1, bar='baz >&baz'),
                           ( ('foo:int', '1'), ('bar', 'baz &gt;&amp;baz') ) )
+
+    def test_toUnicode(self):
+        from Products.CMFDefault.utils import toUnicode
+
+        self.assertEqual( toUnicode('foo'), u'foo' )
+        self.assertEqual( toUnicode( ('foo', 'bar'), 'ascii' ),
+                          (u'foo', u'bar') )
+        self.assertEqual( toUnicode( {'foo': 'bar'}, 'iso-8859-1' ),
+                          {'foo': u'bar'} )
 
 
 def test_suite():



More information about the CMF-checkins mailing list