[Zope-CVS] CVS: Products/ZCTextIndex/tests - testQueryParser.py:1.8
Guido van Rossum
guido@python.org
Fri, 24 May 2002 12:47:56 -0400
Update of /cvs-repository/Products/ZCTextIndex/tests
In directory cvs.zope.org:/tmp/cvs-serv13149/tests
Modified Files:
testQueryParser.py
Log Message:
Move IQueryParseTree to a separate file, to conform to style
guidelines. Added some conformance tests.
=== Products/ZCTextIndex/tests/testQueryParser.py 1.7 => 1.8 ===
from unittest import TestCase, TestSuite, main, makeSuite
-from Products.ZCTextIndex.QueryParser import QueryParser
+from Interface import verify_class_implementation
+
+from Products.ZCTextIndex.IQueryParser import IQueryParser
+from Products.ZCTextIndex.IQueryParseTree import IQueryParseTree
+from Products.ZCTextIndex.QueryParser import QueryParser
from Products.ZCTextIndex.ParseTree import ParseError, ParseTreeNode
from Products.ZCTextIndex.ParseTree import OrNode, AndNode, NotNode
from Products.ZCTextIndex.ParseTree import AtomNode, PhraseNode, GlobNode
from Products.ZCTextIndex.Lexicon import Lexicon, Splitter
+
+class TestInterfaces(TestCase):
+
+ def testInterfaces(self):
+ verify_class_implementation(IQueryParser, QueryParser)
+ verify_class_implementation(IQueryParseTree, ParseTreeNode)
+ verify_class_implementation(IQueryParseTree, OrNode)
+ verify_class_implementation(IQueryParseTree, AndNode)
+ verify_class_implementation(IQueryParseTree, NotNode)
+ verify_class_implementation(IQueryParseTree, AtomNode)
+ verify_class_implementation(IQueryParseTree, PhraseNode)
+ verify_class_implementation(IQueryParseTree, GlobNode)
+
+
class TestQueryParserBase(TestCase):
def setUp(self):
@@ -67,6 +85,7 @@
for i in range(len(list1)):
self.compareParseTrees(list1[i], list2[i], msg)
+
class TestQueryParser(TestQueryParserBase):
def test001(self):
@@ -216,6 +235,7 @@
def test122(self):
self.failure("foo AND -bar")
+
class StopWordTestQueryParser(TestQueryParserBase):
def setUp(self):
@@ -259,6 +279,7 @@
def test306(self):
self.failure('stop AND NOT foo')
+
class FakeStopWordRemover:
def process(self, list):
@@ -268,7 +289,9 @@
def test_suite():
return TestSuite((makeSuite(TestQueryParser),
makeSuite(StopWordTestQueryParser),
+ makeSuite(TestInterfaces),
))
+
if __name__=="__main__":
main(defaultTest='test_suite')