Thank you Andi ! I change the build configuration for jcc and PyLucen to shared mode, and try to build again. It worked!
Thanks again for the detailed explanation! On Fri, Jan 6, 2017 at 11:20 PM, Andi Vajda <va...@apache.org> wrote: > > > On Jan 6, 2017, at 03:02, Shawn Gao <shawn24...@gmail.com> wrote: > > > > Hello, PyLucene User and Developers > > > > Problems occurred during `make test` in pylucene-6.2.0 from PyLucen > > Homepage <http://lucene.apache.org/pylucene> when testing > > 'test_PythonException.py'. And I think there might be something wrong > with > > the test python code. > > This error was just covered on another thread a few days ago: you either > didn't build jcc in shared mode or didn't use --shared then on the jcc > invocation lcommand line in PyLucene's Makefile when building it. The bug > is that this test should be disabled when jcc is not in shared mode since > this exception support depends on it. > > Andi.. > > > > > The test python code I run and the Error Log are posted at the end of > > this email. > > > > The test script raised a python-exception(TestException). But it > return > > a JavaError first, which failed the test. > > > > If I change assertRaises(TestException) to > > assertRaises(lucene.JavaError) here, it passed the test. > > > > Should I make this change to pass the test. Or am I missing something? > > > > > > Thanks for your advice! > > > > > > > > Here comes the python script: > > > > import sys, lucene, unittest > > from PyLuceneTestCase import PyLuceneTestCase > > > > from org.apache.lucene.analysis.standard import StandardAnalyzer > > from org.apache.pylucene.queryparser.classic import PythonQueryParser > > > > > > class PythonExceptionTestCase(PyLuceneTestCase): > > def testThroughLayerException(self): > > class TestException(Exception): > > pass > > > > class TestQueryParser(PythonQueryParser): > > def getFieldQuery_quoted(_self, field, queryText, quoted): > > raise TestException("TestException") > > > > qp = TestQueryParser('all', StandardAnalyzer()) > > > > with self.assertRaises(TestException): > > qp.parse("foo bar") > > > > if __name__ == "__main__": > > lucene.initVM(vmargs=['-Djava.awt.headless=true']) > > if '-loop' in sys.argv: > > print "in if" > > sys.argv.remove('-loop') > > while True: > > try: > > unittest.main() > > except: > > pass > > else: > > print "in else" > > unittest.main() > > > > > > Here's the Error StackTrace: > > > > > > shawn@shawn-Precision-T1700:~/workspace/pylucene-6.2.0/test$ python > > ./test_PythonException.py > > in else > > E > > ====================================================================== > > ERROR: testThroughLayerException (__main__.PythonExceptionTestCase) > > ---------------------------------------------------------------------- > > Traceback (most recent call last): > > File "./test_PythonException.py", line 34, in testThroughLayerException > > qp.parse("foo bar") > > JavaError: <super: <class 'JavaError'>, <JavaError object>> > > Java stacktrace: > > java.lang.RuntimeException: TestException > > at org.apache.pylucene.queryparser.classic.PythonQueryParser. > getFieldQuery_quoted(Native > > Method) > > at org.apache.pylucene.queryparser.classic.PythonQueryParser. > getFieldQuery(Unknown > > Source) > > at org.apache.lucene.queryparser.classic.QueryParser.MultiTerm( > > QueryParser.java:585) > > at org.apache.lucene.queryparser.classic.QueryParser.Query( > > QueryParser.java:198) > > at org.apache.lucene.queryparser.classic.QueryParser. > > TopLevelQuery(QueryParser.java:187) > > at org.apache.lucene.queryparser.classic.QueryParserBase.parse( > > QueryParserBase.java:111) > >