[Zope-Checkins] CVS: Zope/lib/python/Products/ZCTextIndex/tests - testLexicon.py:1.5
Guido van Rossum
guido@python.org
Thu, 19 Dec 2002 10:39:29 -0500
Update of /cvs-repository/Zope/lib/python/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv19581
Modified Files:
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.4 => 1.5 ===
--- Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py:1.4 Mon Dec 2 00:27:51 2002
+++ Zope/lib/python/Products/ZCTextIndex/tests/testLexicon.py Thu Dec 19 10:39:29 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():