[Zope-Checkins] CVS: Zope/lib/python/Products/ZCTextIndex/tests - testLexicon.py:1.4 testStopper.py:1.3
Casey Duncan
casey@zope.com
Mon, 2 Dec 2002 00:27:53 -0500
Update of /cvs-repository/Zope/lib/python/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv8135/tests
Modified Files:
testLexicon.py testStopper.py
Log Message:
Collector #597: Added locale support to ZCTextindex splitters. Added unittest
Added ZPL header to stopper test module
=== Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py 1.3 => 1.4 ===
--- Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py:1.3 Thu May 16 15:51:12 2002
+++ Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py Mon Dec 2 00:27:51 2002
@@ -12,6 +12,7 @@
#
##############################################################################
+import sys
from unittest import TestCase, TestSuite, main, makeSuite
from Products.ZCTextIndex.Lexicon import Lexicon
@@ -112,7 +113,24 @@
wids = lexicon.sourceToWordIds('cats and dogs')
wids = lexicon.termToWordIds('hsif')
self.assertEqual(wids, [2])
-
+
+ def testSplitterLocaleAwareness(self):
+ from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter
+ import locale
+ loc = locale.setlocale(locale.LC_ALL) # get current locale
+ # set German locale
+ if sys.platform != 'win32':
+ locale.setlocale(locale.LC_ALL, 'de_DE.ISO8859-1')
+ else:
+ locale.setlocale(locale.LC_ALL, 'German_Germany.1252')
+ words = ['mülltonne waschbär behörde überflieger']
+ words = Splitter().process(words)
+ self.assertEqual(
+ words, ['mülltonne', 'waschbär', 'behörde', 'überflieger'])
+ words = HTMLWordSplitter().process(words)
+ self.assertEqual(
+ words, ['mülltonne', 'waschbär', 'behörde', 'überflieger'])
+ locale.setlocale(locale.LC_ALL, loc) # restore saved locale
def test_suite():
return makeSuite(Test)
=== Zope/lib/python/Products/ZCTextIndex/tests/testStopper.py 1.2 => 1.3 ===
--- Zope/lib/python/Products/ZCTextIndex/tests/testStopper.py:1.2 Wed May 22 12:44:54 2002
+++ Zope/lib/python/Products/ZCTextIndex/tests/testStopper.py Mon Dec 2 00:27:51 2002
@@ -1,3 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
"""Tests for the C version of the StopWordRemover."""
import unittest