Commit d2e5544e authored by Guido van Rossum's avatar Guido van Rossum

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.
parent a029fbbb
......@@ -119,17 +119,20 @@ class Test(TestCase):
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 = ['mlltonne waschbr behrde 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, ['mlltonne', 'waschbr', 'behrde', 'berflieger'])
self.assertEqual(words, expected)
words = HTMLWordSplitter().process(words)
self.assertEqual(
words, ['mlltonne', 'waschbr', 'behrde', 'berflieger'])
self.assertEqual(words, expected)
locale.setlocale(locale.LC_ALL, loc) # restore saved locale
def test_suite():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment