[Zope-Checkins] CVS: Zope/lib/python/Products/ZCTextIndex/tests - testLexicon.py:1.3.10.2

Guido van Rossum guido@python.org
Thu, 19 Dec 2002 10:37:36 -0500


Update of /cvs-repository/Zope/lib/python/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv19312

Modified Files:
      Tag: Zope-2_6-branch
	testLexicon.py 
Log Message:
Backport two fixes to testSplitterLocaleAwareness() from the Zope 3
version:

- If the setlocale() call fails, don't fail the test -- just skip it
  silently.  XXX This is not ideal, but what else can we do?  Locale
  names are not standardized; the test fails on Mac OSX, and
  apparently on older Linux versions (e.g. my Mandrake 8.1).

- Don't use non-ASCII literals; use \xXX escapes.


=== Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py 1.3.10.1 => 1.3.10.2 ===
--- Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py:1.3.10.1	Mon Dec  2 01:08:51 2002
+++ Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py	Thu Dec 19 10:37:36 2002
@@ -119,17 +119,20 @@
         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']
+        try:
+            if sys.platform != 'win32':
+                locale.setlocale(locale.LC_ALL, 'de_DE.ISO8859-1')
+            else:
+                locale.setlocale(locale.LC_ALL, 'German_Germany.1252')
+        except locale.Error:
+            return # This test doesn't work here :-(
+        expected = ['m\xfclltonne', 'waschb\xe4r',
+                    'beh\xf6rde', '\xfcberflieger']
+        words = [" ".join(expected)]
         words = Splitter().process(words)
-        self.assertEqual(
-            words, ['mülltonne', 'waschbär', 'behörde', 'überflieger'])
+        self.assertEqual(words, expected)
         words = HTMLWordSplitter().process(words)
-        self.assertEqual(
-            words, ['mülltonne', 'waschbär', 'behörde', 'überflieger'])        
+        self.assertEqual(words, expected)
         locale.setlocale(locale.LC_ALL, loc) # restore saved locale
 
 def test_suite():