lucene-pylucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r1359643 - in /lucene/pylucene/trunk/test: PyLuceneTestCase.py test_BinaryDocument.py test_RegexQuery.py
Date Tue, 10 Jul 2012 12:50:30 GMT
Author: vajda
Date: Tue Jul 10 12:50:29 2012
New Revision: 1359643

URL: http://svn.apache.org/viewvc?rev=1359643&view=rev
Log:
added PyLuceneTestCase.py (Roman Chyla)

Added:
    lucene/pylucene/trunk/test/PyLuceneTestCase.py   (with props)
Modified:
    lucene/pylucene/trunk/test/test_BinaryDocument.py
    lucene/pylucene/trunk/test/test_RegexQuery.py

Added: lucene/pylucene/trunk/test/PyLuceneTestCase.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/test/PyLuceneTestCase.py?rev=1359643&view=auto
==============================================================================
--- lucene/pylucene/trunk/test/PyLuceneTestCase.py (added)
+++ lucene/pylucene/trunk/test/PyLuceneTestCase.py Tue Jul 10 12:50:29 2012
@@ -0,0 +1,46 @@
+# ====================================================================
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+# ====================================================================
+
+
+from unittest import TestCase
+from lucene import RAMDirectory, File, IndexWriter, IndexWriterConfig, \
+    LimitTokenCountAnalyzer, WhitespaceAnalyzer, Version, IndexSearcher, \
+    DirectoryReader
+
+class PyLuceneTestCase(TestCase):
+
+    def __init__(self, *args):
+        super(PyLuceneTestCase, self).__init__(*args)
+        self.TEST_VERSION = Version.LUCENE_CURRENT
+
+    def setUp(self):
+        self.directory = RAMDirectory()
+
+    def tearDown(self):
+        self.directory.close()
+        
+    def getWriter(self, directory=None, analyzer=None, open_mode=None):
+        config = IndexWriterConfig(self.TEST_VERSION,
+                                   analyzer or LimitTokenCountAnalyzer(WhitespaceAnalyzer(Version.LUCENE_CURRENT),
10000))
+        config.setOpenMode(open_mode or IndexWriterConfig.OpenMode.CREATE)
+
+        return IndexWriter(directory or self.directory, config)
+        
+    def getSearcher(self, directory=None, reader=None):
+        if reader is not None:
+            return IndexSearcher(reader)
+        return IndexSearcher(self.getReader(directory=directory))
+    
+    def getReader(self, directory=None):
+        return DirectoryReader.open(directory or self.directory)

Propchange: lucene/pylucene/trunk/test/PyLuceneTestCase.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/pylucene/trunk/test/PyLuceneTestCase.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: lucene/pylucene/trunk/test/test_BinaryDocument.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/test/test_BinaryDocument.py?rev=1359643&r1=1359642&r2=1359643&view=diff
==============================================================================
--- lucene/pylucene/trunk/test/test_BinaryDocument.py (original)
+++ lucene/pylucene/trunk/test/test_BinaryDocument.py Tue Jul 10 12:50:29 2012
@@ -12,9 +12,9 @@
 #   limitations under the License.
 # ====================================================================
 
-from pylucene_testcase import PyLuceneTestCase
 from unittest import TestCase, main
 from lucene import *
+from PyLuceneTestCase import PyLuceneTestCase
 
 
 class TestBinaryDocument(PyLuceneTestCase):
@@ -32,7 +32,6 @@ class TestBinaryDocument(PyLuceneTestCas
         ft.setStoreTermVectors(False)
         stringFldStored = Field("stringStored", self.binaryValStored, ft)
         
-        
         # couldn't find any combination with lucene4.0 where it would raise errors
         #try:
         #    # binary fields with store off are not allowed
@@ -47,8 +46,6 @@ class TestBinaryDocument(PyLuceneTestCas
         doc.add(binaryFldStored)
         doc.add(stringFldStored)
         
-        
-
         # test for field count
         self.assertEqual(2, doc.fields.size())
     
@@ -65,7 +62,7 @@ class TestBinaryDocument(PyLuceneTestCas
         # fetch the binary stored field and compare it's content with the
         # original one
         bytes = docFromReader.getBinaryValue("binaryStored")
-        binaryFldStoredTest = bytes.string_
+        binaryFldStoredTest = bytes.bytes.string_
         self.assertEqual(binaryFldStoredTest, self.binaryValStored)
         
         # fetch the string field and compare it's content with the original

Modified: lucene/pylucene/trunk/test/test_RegexQuery.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/test/test_RegexQuery.py?rev=1359643&r1=1359642&r2=1359643&view=diff
==============================================================================
--- lucene/pylucene/trunk/test/test_RegexQuery.py (original)
+++ lucene/pylucene/trunk/test/test_RegexQuery.py Tue Jul 10 12:50:29 2012
@@ -14,10 +14,10 @@
 
 from unittest import TestCase, main
 from lucene import *
-from pylucene_testcase import PyLuceneTestCase
+from PyLuceneTestCase import PyLuceneTestCase
 
-class TestRegexQuery(PyLuceneTestCase):
 
+class TestRegexQuery(PyLuceneTestCase):
     FN = "field"
 
     def setUp(self):



Mime
View raw message