[Zope-Checkins] CVS: Products/PluginIndexes/TextIndex/tests - testSplitter.py:1.2.16.1

Andreas Jung andreas@digicool.com
Mon, 30 Jul 2001 09:51:44 -0400


Update of /cvs-repository/Products/PluginIndexes/TextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv31400

Modified Files:
      Tag: zope2-testunitfix
	testSplitter.py 
Log Message:
Collector #2458: improved import statement for Splitter module


 
=== Products/PluginIndexes/TextIndex/tests/testSplitter.py 1.2 => 1.2.16.1 ===
     import Testing
 
-import unittest
-from Products.PluginIndexes.PathIndex.PathIndex import PathIndex
-
-
+import unittest,locale
 import Splitter
 
 
@@ -104,8 +101,13 @@
     """
 
     def setUp( self ):
-        """
-        """
+        self.testdata = (
+        ('The quick brown fox jumps over the lazy dog',
+          ['the','quick','brown','fox','jumps','over','the','lazy','dog']),
+        (  'öfters   Österreichische   herüber   Überfall   daß   Ärger   verärgert',
+          ['öfters','österreichische','herüber','überfall','daß','ärger','verärgert'])
+        )
+        
 
         pass
 
@@ -122,7 +124,29 @@
         assert len(Splitter.availableSplitters)==len(Splitter.splitterNames)
 
 
+
+    def _test(self,sp_name,text,splitted):
+    
+        splitter = Splitter.getSplitter(sp_name)
+        result = list(splitter(text))
+
+        assert result==splitted, "%s: %s vs %s" % (sp_name,result,splitted) 
+
+
+    def testZopeSplitter(self):
+        """test ZopeSplitter"""
+
+        for text,splitted in self.testdata:
+            self._test("ZopeSplitter",text,splitted)
     
+    def testISOSplitter(self):
+        """test ISOSplitter"""
+
+        for text,splitted in self.testdata:
+            self._test("ISO_8859_1_Splitter",text,splitted)
+
+#        for loc in ["","ru_RU.KOI8-R"]:
+#           locale.setlocale(locale.LC_ALL , loc)