1 # ====================================================================
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13 # ====================================================================
15 from unittest import TestCase, main
19 class NotTestCase(TestCase):
21 Unit tests ported from Java Lucene
26 store = RAMDirectory()
27 writer = IndexWriter(store, SimpleAnalyzer(Version.LUCENE_CURRENT),
28 True, IndexWriter.MaxFieldLength.LIMITED)
31 d1.add(Field("field", "a b", Field.Store.YES, Field.Index.ANALYZED))
33 writer.addDocument(d1)
37 searcher = IndexSearcher(store, True)
38 query = QueryParser(Version.LUCENE_CURRENT, "field",
39 SimpleAnalyzer(Version.LUCENE_CURRENT)).parse("a NOT b")
41 topDocs = searcher.search(query, 50)
42 self.assertEqual(0, topDocs.totalHits)
45 if __name__ == "__main__":
48 if '-loop' in sys.argv:
49 sys.argv.remove('-loop')