[Checkins] SVN: zope.index/trunk/src/zope/index/text/ 100% coverage for zope.index.text.htmlsplitter module.
Tres Seaver
tseaver at palladion.com
Wed Jun 10 18:10:07 EDT 2009
Log message for revision 100816:
100% coverage for zope.index.text.htmlsplitter module.
Changed:
U zope.index/trunk/src/zope/index/text/htmlsplitter.py
A zope.index/trunk/src/zope/index/text/tests/test_htmlsplitter.py
-=-
Modified: zope.index/trunk/src/zope/index/text/htmlsplitter.py
===================================================================
--- zope.index/trunk/src/zope/index/text/htmlsplitter.py 2009-06-10 22:03:27 UTC (rev 100815)
+++ zope.index/trunk/src/zope/index/text/htmlsplitter.py 2009-06-10 22:10:07 UTC (rev 100816)
@@ -42,13 +42,3 @@
for pat in remove:
text = re.sub(pat, " ", text)
return re.findall(wordpat, text)
-
-if __name__ == "__main__":
- import sys
- splitter = HTMLWordSplitter()
- for path in sys.argv[1:]:
- f = open(path, "rb")
- buf = f.read()
- f.close()
- print path
- print splitter.process([buf])
Added: zope.index/trunk/src/zope/index/text/tests/test_htmlsplitter.py
===================================================================
--- zope.index/trunk/src/zope/index/text/tests/test_htmlsplitter.py (rev 0)
+++ zope.index/trunk/src/zope/index/text/tests/test_htmlsplitter.py 2009-06-10 22:10:07 UTC (rev 100816)
@@ -0,0 +1,77 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Test zope.index.text.htmlsplitter
+"""
+import unittest
+
+class HTMLWordSplitterTests(unittest.TestCase):
+ # Subclasses must define '_getBTreesFamily'
+ def _getTargetClass(self):
+ from zope.index.text.htmlsplitter import HTMLWordSplitter
+ return HTMLWordSplitter
+
+ def _makeOne(self):
+ return self._getTargetClass()()
+
+ def test_class_conforms_to_ISplitter(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.text.interfaces import ISplitter
+ verifyClass(ISplitter, self._getTargetClass())
+
+ def test_instance_conforms_to_ISplitter(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.text.interfaces import ISplitter
+ verifyObject(ISplitter, self._makeOne())
+
+ def test_process_empty_string(self):
+ splitter = self._makeOne()
+ self.assertEqual(splitter.process(['']), [])
+
+ def test_process_no_markup(self):
+ splitter = self._makeOne()
+ self.assertEqual(splitter.process(['abc def']), ['abc', 'def'])
+
+ def test_process_w_markup(self):
+ splitter = self._makeOne()
+ self.assertEqual(splitter.process(['<h1>abc</h1> <p>def</p>']),
+ ['abc', 'def'])
+
+ def test_process_no_markup_w_glob(self):
+ splitter = self._makeOne()
+ self.assertEqual(splitter.process(['abc?def hij*klm nop* qrs?']),
+ ['abc', 'def', 'hij', 'klm', 'nop', 'qrs'])
+
+ def test_processGlob_empty_string(self):
+ splitter = self._makeOne()
+ self.assertEqual(splitter.processGlob(['']), [])
+
+ def test_processGlob_no_markup_no_glob(self):
+ splitter = self._makeOne()
+ self.assertEqual(splitter.processGlob(['abc def']), ['abc', 'def'])
+
+ def test_processGlob_w_markup_no_glob(self):
+ splitter = self._makeOne()
+ self.assertEqual(splitter.processGlob(['<h1>abc</h1> '
+ '<p>def</p>']),
+ ['abc', 'def'])
+
+ def test_processGlob_no_markup_w_glob(self):
+ splitter = self._makeOne()
+ self.assertEqual(splitter.processGlob(['abc?def hij*klm nop* qrs?']),
+ ['abc?def', 'hij*klm', 'nop*', 'qrs?'])
+
+def test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(HTMLWordSplitterTests),
+ ))
More information about the Checkins
mailing list