Skip to content

Commit

Permalink
100% for test_lexicon.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Nov 2, 2017
1 parent 4b92744 commit 15fa1f0
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions src/zope/index/text/tests/test_lexicon.py
Expand Up @@ -209,12 +209,6 @@ def test__new_wid_recovers_from_damaged_length(self):
self.assertEqual(lexicon.wordCount(), 4)

class SplitterTests(unittest.TestCase):
_old_locale = None

def tearDown(self):
if self._old_locale is not None:
import locale
locale.setlocale(locale.LC_ALL, self._old_locale)

def _getTargetClass(self):
from zope.index.text.lexicon import Splitter
Expand Down Expand Up @@ -244,15 +238,15 @@ def test_process_simple(self):
def test_process_w_locale_awareness(self):
import locale
import sys
self._old_locale = locale.setlocale(locale.LC_ALL)
old_locale = locale.setlocale(locale.LC_ALL)
# set German locale
try:
if sys.platform == 'win32':
locale.setlocale(locale.LC_ALL, 'German_Germany.1252')
else:
locale.setlocale(locale.LC_ALL, 'de_DE.ISO8859-1')
except locale.Error:
locale_string = 'de_DE.ISO8859-1' if sys.platform != 'win32' else 'German_Germany.1252'
locale.setlocale(locale.LC_ALL, locale_string)
except locale.Error: # pragma: no cover
return # This test doesn't work here :-(
self.addCleanup(locale.setlocale, locale.LC_ALL, old_locale)

expected = ['m\xfclltonne', 'waschb\xe4r',
'beh\xf6rde', '\xfcberflieger']
splitter = self._makeOne()
Expand Down Expand Up @@ -392,7 +386,8 @@ def process(self, seq):
return res

class StopWordPipelineElement(object):
def __init__(self, stopdict={}):

def __init__(self, stopdict):
self.__stopdict = stopdict

def process(self, seq):
Expand All @@ -403,12 +398,3 @@ def process(self, seq):
else:
res.append(term)
return res

def test_suite():
return unittest.TestSuite((
unittest.makeSuite(LexiconTests),
unittest.makeSuite(SplitterTests),
unittest.makeSuite(CaseNormalizerTests),
unittest.makeSuite(StopWordRemoverTests),
unittest.makeSuite(StopWordAndSingleCharRemoverTests),
))

0 comments on commit 15fa1f0

Please sign in to comment.