[Checkins] SVN: zope.index/trunk/src/zope/index/text/tests/test_ Normalize test module names.
Tres Seaver
tseaver at palladion.com
Wed Jun 10 19:49:31 EDT 2009
Log message for revision 100822:
Normalize test module names.
Changed:
D zope.index/trunk/src/zope/index/text/tests/test_cosine.py
A zope.index/trunk/src/zope/index/text/tests/test_cosineindex.py
D zope.index/trunk/src/zope/index/text/tests/test_okapi.py
A zope.index/trunk/src/zope/index/text/tests/test_okapiindex.py
-=-
Deleted: zope.index/trunk/src/zope/index/text/tests/test_cosine.py
===================================================================
--- zope.index/trunk/src/zope/index/text/tests/test_cosine.py 2009-06-10 23:48:01 UTC (rev 100821)
+++ zope.index/trunk/src/zope/index/text/tests/test_cosine.py 2009-06-10 23:49:31 UTC (rev 100822)
@@ -1,116 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2002, 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.
-#
-##############################################################################
-"""Text Index Tests
-
-$Id: test_index.py 100805 2009-06-10 17:58:58Z tseaver $
-"""
-import unittest
-
-class CosineIndexTestBase:
- # Subclasses must define '_getBTreesFamily'
- def _getTargetClass(self):
- from zope.index.text.cosineindex import CosineIndex
- return CosineIndex
-
- def _makeOne(self):
- from zope.index.text.lexicon import Lexicon
- from zope.index.text.lexicon import Splitter
- lexicon = Lexicon(Splitter())
- return self._getTargetClass()(lexicon, family=self._getBTreesFamily())
-
- def test_class_conforms_to_IInjection(self):
- from zope.interface.verify import verifyClass
- from zope.index.interfaces import IInjection
- verifyClass(IInjection, self._getTargetClass())
-
- def test_instance_conforms_to_IInjection(self):
- from zope.interface.verify import verifyObject
- from zope.index.interfaces import IInjection
- verifyObject(IInjection, self._makeOne())
-
- def test_class_conforms_to_IStatistics(self):
- from zope.interface.verify import verifyClass
- from zope.index.interfaces import IStatistics
- verifyClass(IStatistics, self._getTargetClass())
-
- def test_instance_conforms_to_IStatistics(self):
- from zope.interface.verify import verifyObject
- from zope.index.interfaces import IStatistics
- verifyObject(IStatistics, self._makeOne())
-
- def test_class_conforms_to_IExtendedQuerying(self):
- from zope.interface.verify import verifyClass
- from zope.index.text.interfaces import IExtendedQuerying
- verifyClass(IExtendedQuerying, self._getTargetClass())
-
- def test_instance_conforms_to_IExtendedQuerying(self):
- from zope.interface.verify import verifyObject
- from zope.index.text.interfaces import IExtendedQuerying
- verifyObject(IExtendedQuerying, self._makeOne())
-
- def test__search_wids_empty_wids(self):
- index = self._makeOne()
- index.index_doc(1, 'one two three')
- self.assertEqual(index._search_wids(()), [])
-
- def test__search_wids_non_empty_wids(self):
- TEXT = 'one two three'
- index = self._makeOne()
- index.index_doc(1, TEXT )
- wids = [index._lexicon._wids[x] for x in TEXT.split()]
- relevances = index._search_wids(wids)
- self.assertEqual(len(relevances), len(wids))
- for relevance in relevances:
- self.failUnless(isinstance(relevance[0], index.family.IF.Bucket))
- self.assertEqual(len(relevance[0]), 1)
- self.failUnless(isinstance(relevance[0][1], float))
- self.failUnless(isinstance(relevance[1], float))
-
- def test_query_weight_empty_wids(self):
- index = self._makeOne()
- index.index_doc(1, 'one two three')
- self.assertEqual(index.query_weight(()), 0.0)
-
- def test_query_weight_oov_wids(self):
- index = self._makeOne()
- index.index_doc(1, 'one two three')
- self.assertEqual(index.query_weight(['nonesuch']), 0.0)
-
- def test_query_weight_hit_single_occurence(self):
- index = self._makeOne()
- index.index_doc(1, 'one two three')
- self.failUnless(0.0 < index.query_weight(['one']) < 1.0)
-
- def test_query_weight_hit_multiple_occurences(self):
- index = self._makeOne()
- index.index_doc(1, 'one one two three one')
- self.failUnless(0.0 < index.query_weight(['one']) < 1.0)
-
-class CosineIndexTest32(CosineIndexTestBase, unittest.TestCase):
-
- def _getBTreesFamily(self):
- import BTrees
- return BTrees.family32
-
-class CosineIndexTest64(CosineIndexTestBase, unittest.TestCase):
-
- def _getBTreesFamily(self):
- import BTrees
- return BTrees.family64
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(CosineIndexTest32),
- unittest.makeSuite(CosineIndexTest64),
- ))
Copied: zope.index/trunk/src/zope/index/text/tests/test_cosineindex.py (from rev 100814, zope.index/trunk/src/zope/index/text/tests/test_cosine.py)
===================================================================
--- zope.index/trunk/src/zope/index/text/tests/test_cosineindex.py (rev 0)
+++ zope.index/trunk/src/zope/index/text/tests/test_cosineindex.py 2009-06-10 23:49:31 UTC (rev 100822)
@@ -0,0 +1,116 @@
+##############################################################################
+#
+# Copyright (c) 2002, 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.
+#
+##############################################################################
+"""Text Index Tests
+
+$Id: test_index.py 100805 2009-06-10 17:58:58Z tseaver $
+"""
+import unittest
+
+class CosineIndexTestBase:
+ # Subclasses must define '_getBTreesFamily'
+ def _getTargetClass(self):
+ from zope.index.text.cosineindex import CosineIndex
+ return CosineIndex
+
+ def _makeOne(self):
+ from zope.index.text.lexicon import Lexicon
+ from zope.index.text.lexicon import Splitter
+ lexicon = Lexicon(Splitter())
+ return self._getTargetClass()(lexicon, family=self._getBTreesFamily())
+
+ def test_class_conforms_to_IInjection(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.interfaces import IInjection
+ verifyClass(IInjection, self._getTargetClass())
+
+ def test_instance_conforms_to_IInjection(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.interfaces import IInjection
+ verifyObject(IInjection, self._makeOne())
+
+ def test_class_conforms_to_IStatistics(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.interfaces import IStatistics
+ verifyClass(IStatistics, self._getTargetClass())
+
+ def test_instance_conforms_to_IStatistics(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.interfaces import IStatistics
+ verifyObject(IStatistics, self._makeOne())
+
+ def test_class_conforms_to_IExtendedQuerying(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.text.interfaces import IExtendedQuerying
+ verifyClass(IExtendedQuerying, self._getTargetClass())
+
+ def test_instance_conforms_to_IExtendedQuerying(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.text.interfaces import IExtendedQuerying
+ verifyObject(IExtendedQuerying, self._makeOne())
+
+ def test__search_wids_empty_wids(self):
+ index = self._makeOne()
+ index.index_doc(1, 'one two three')
+ self.assertEqual(index._search_wids(()), [])
+
+ def test__search_wids_non_empty_wids(self):
+ TEXT = 'one two three'
+ index = self._makeOne()
+ index.index_doc(1, TEXT )
+ wids = [index._lexicon._wids[x] for x in TEXT.split()]
+ relevances = index._search_wids(wids)
+ self.assertEqual(len(relevances), len(wids))
+ for relevance in relevances:
+ self.failUnless(isinstance(relevance[0], index.family.IF.Bucket))
+ self.assertEqual(len(relevance[0]), 1)
+ self.failUnless(isinstance(relevance[0][1], float))
+ self.failUnless(isinstance(relevance[1], float))
+
+ def test_query_weight_empty_wids(self):
+ index = self._makeOne()
+ index.index_doc(1, 'one two three')
+ self.assertEqual(index.query_weight(()), 0.0)
+
+ def test_query_weight_oov_wids(self):
+ index = self._makeOne()
+ index.index_doc(1, 'one two three')
+ self.assertEqual(index.query_weight(['nonesuch']), 0.0)
+
+ def test_query_weight_hit_single_occurence(self):
+ index = self._makeOne()
+ index.index_doc(1, 'one two three')
+ self.failUnless(0.0 < index.query_weight(['one']) < 1.0)
+
+ def test_query_weight_hit_multiple_occurences(self):
+ index = self._makeOne()
+ index.index_doc(1, 'one one two three one')
+ self.failUnless(0.0 < index.query_weight(['one']) < 1.0)
+
+class CosineIndexTest32(CosineIndexTestBase, unittest.TestCase):
+
+ def _getBTreesFamily(self):
+ import BTrees
+ return BTrees.family32
+
+class CosineIndexTest64(CosineIndexTestBase, unittest.TestCase):
+
+ def _getBTreesFamily(self):
+ import BTrees
+ return BTrees.family64
+
+def test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(CosineIndexTest32),
+ unittest.makeSuite(CosineIndexTest64),
+ ))
Deleted: zope.index/trunk/src/zope/index/text/tests/test_okapi.py
===================================================================
--- zope.index/trunk/src/zope/index/text/tests/test_okapi.py 2009-06-10 23:48:01 UTC (rev 100821)
+++ zope.index/trunk/src/zope/index/text/tests/test_okapi.py 2009-06-10 23:49:31 UTC (rev 100822)
@@ -1,80 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""Okapi text index tests
-"""
-import unittest
-
-class OkapiIndexTestBase:
- # Subclasses must define '_getBTreesFamily'
- def _getTargetClass(self):
- from zope.index.text.okapiindex import OkapiIndex
- return OkapiIndex
-
- def _makeOne(self):
- from zope.index.text.lexicon import Lexicon
- from zope.index.text.lexicon import Splitter
- lexicon = Lexicon(Splitter())
- return self._getTargetClass()(lexicon, family=self._getBTreesFamily())
-
- def test_class_conforms_to_IInjection(self):
- from zope.interface.verify import verifyClass
- from zope.index.interfaces import IInjection
- verifyClass(IInjection, self._getTargetClass())
-
- def test_instance_conforms_to_IInjection(self):
- from zope.interface.verify import verifyObject
- from zope.index.interfaces import IInjection
- verifyObject(IInjection, self._makeOne())
-
- def test_class_conforms_to_IStatistics(self):
- from zope.interface.verify import verifyClass
- from zope.index.interfaces import IStatistics
- verifyClass(IStatistics, self._getTargetClass())
-
- def test_instance_conforms_to_IStatistics(self):
- from zope.interface.verify import verifyObject
- from zope.index.interfaces import IStatistics
- verifyObject(IStatistics, self._makeOne())
-
- def test_class_conforms_to_IExtendedQuerying(self):
- from zope.interface.verify import verifyClass
- from zope.index.text.interfaces import IExtendedQuerying
- verifyClass(IExtendedQuerying, self._getTargetClass())
-
- def test_instance_conforms_to_IExtendedQuerying(self):
- from zope.interface.verify import verifyObject
- from zope.index.text.interfaces import IExtendedQuerying
- verifyObject(IExtendedQuerying, self._makeOne())
-
- def test_empty(self):
- index = self._makeOne()
- self.assertEqual(index._totaldoclen(), 0)
-
-class OkapiIndexTest32(OkapiIndexTestBase, unittest.TestCase):
-
- def _getBTreesFamily(self):
- import BTrees
- return BTrees.family32
-
-class OkapiIndexTest64(OkapiIndexTestBase, unittest.TestCase):
-
- def _getBTreesFamily(self):
- import BTrees
- return BTrees.family64
-
-def test_suite():
- return unittest.TestSuite((
- unittest.makeSuite(OkapiIndexTest32),
- unittest.makeSuite(OkapiIndexTest64),
- ))
Copied: zope.index/trunk/src/zope/index/text/tests/test_okapiindex.py (from rev 100807, zope.index/trunk/src/zope/index/text/tests/test_okapi.py)
===================================================================
--- zope.index/trunk/src/zope/index/text/tests/test_okapiindex.py (rev 0)
+++ zope.index/trunk/src/zope/index/text/tests/test_okapiindex.py 2009-06-10 23:49:31 UTC (rev 100822)
@@ -0,0 +1,80 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Okapi text index tests
+"""
+import unittest
+
+class OkapiIndexTestBase:
+ # Subclasses must define '_getBTreesFamily'
+ def _getTargetClass(self):
+ from zope.index.text.okapiindex import OkapiIndex
+ return OkapiIndex
+
+ def _makeOne(self):
+ from zope.index.text.lexicon import Lexicon
+ from zope.index.text.lexicon import Splitter
+ lexicon = Lexicon(Splitter())
+ return self._getTargetClass()(lexicon, family=self._getBTreesFamily())
+
+ def test_class_conforms_to_IInjection(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.interfaces import IInjection
+ verifyClass(IInjection, self._getTargetClass())
+
+ def test_instance_conforms_to_IInjection(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.interfaces import IInjection
+ verifyObject(IInjection, self._makeOne())
+
+ def test_class_conforms_to_IStatistics(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.interfaces import IStatistics
+ verifyClass(IStatistics, self._getTargetClass())
+
+ def test_instance_conforms_to_IStatistics(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.interfaces import IStatistics
+ verifyObject(IStatistics, self._makeOne())
+
+ def test_class_conforms_to_IExtendedQuerying(self):
+ from zope.interface.verify import verifyClass
+ from zope.index.text.interfaces import IExtendedQuerying
+ verifyClass(IExtendedQuerying, self._getTargetClass())
+
+ def test_instance_conforms_to_IExtendedQuerying(self):
+ from zope.interface.verify import verifyObject
+ from zope.index.text.interfaces import IExtendedQuerying
+ verifyObject(IExtendedQuerying, self._makeOne())
+
+ def test_empty(self):
+ index = self._makeOne()
+ self.assertEqual(index._totaldoclen(), 0)
+
+class OkapiIndexTest32(OkapiIndexTestBase, unittest.TestCase):
+
+ def _getBTreesFamily(self):
+ import BTrees
+ return BTrees.family32
+
+class OkapiIndexTest64(OkapiIndexTestBase, unittest.TestCase):
+
+ def _getBTreesFamily(self):
+ import BTrees
+ return BTrees.family64
+
+def test_suite():
+ return unittest.TestSuite((
+ unittest.makeSuite(OkapiIndexTest32),
+ unittest.makeSuite(OkapiIndexTest64),
+ ))
More information about the Checkins
mailing list