[Zope-CVS] CVS: Products/ZCTextIndex/tests - testStopper.py:1.2
Fred L. Drake, Jr.
fdrake@acm.org
Wed, 22 May 2002 12:44:55 -0400
Update of /cvs-repository/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv22954/tests
Modified Files:
testStopper.py
Log Message:
Simplify the "stopper" helper module -- just define a simple function
instead of an extension type, and let StopWordRemover be a Python class
that uses the helper if available.
=== Products/ZCTextIndex/tests/testStopper.py 1.1 => 1.2 ===
class StopperTest(unittest.TestCase):
- def test_constructor_empty(self):
- s = stopper.new()
- self.assertEqual(s.dict, {})
-
- def test_constructor_dict(self):
- d = {}
- s = stopper.new(d)
- self.assert_(s.dict is d)
-
- def test_constructor_error(self):
- self.assertRaises(TypeError, stopper.new, [])
- self.assertRaises(TypeError, stopper.new, {}, 'extra arg')
+ def test_process_typeerror(self):
+ self.assertRaises(TypeError, stopper.process, 42, [])
+ self.assertRaises(TypeError, stopper.process, {}, 42)
+ self.assertRaises(TypeError, stopper.process, {})
+ self.assertRaises(TypeError, stopper.process, {}, [], 'extra arg')
def test_process_nostops(self):
- s = stopper.new()
words = ['a', 'b', 'c', 'splat!']
- self.assertEqual(words, s.process(words))
+ self.assertEqual(words, stopper.process({}, words))
def test_process_somestops(self):
- s = stopper.new({'b':1, 'splat!':1})
+ d = {'b':1, 'splat!':1}
words = ['a', 'b', 'c', 'splat!']
- self.assertEqual(['a', 'c'], s.process(words))
+ self.assertEqual(['a', 'c'], stopper.process(d, words))
def test_process_allstops(self):
- s = stopper.new({'a':1, 'b':1, 'c':1, 'splat!':1})
+ d = {'a':1, 'b':1, 'c':1, 'splat!':1}
words = ['a', 'b', 'c', 'splat!']
- self.assertEqual([], s.process(words))
+ self.assertEqual([], stopper.process(d, words))
def test_suite():