daevaorn / djapian

High level Xapian integration for Django
Other
6 stars 3 forks source link

AssertionError on djapian.tests.query._QueryTest_subject:test and djapian.tests.query._QueryTest_title:test #121

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
When using Djapian 2.3.1 and running its unit tests, I get an AssertionError on 
both the djapian.tests.query._QueryTest_subject:test test and the 
djapian.tests.query._QueryTest_title:test test.

Traceback (most recent call last):
  File "/djapian/tests/query.py", line 10, in test_result_count
    self.assertEqual(len(self.result), count)
AssertionError: 3 != 2

Could this be because the first 3 Entry objects that are created in setUp() in 
djapian/tests/utils.py/BaseIndexerTest each contain a title with the word 
"test" in it? It looks like you may have forgotten that the third Entry object 
has "test" in the word "testing" in its title attribute.

Original issue reported on code.google.com by clevelan...@gmail.com on 10 Nov 2010 at 9:14

GoogleCodeExporter commented 9 years ago
We are quite far away from 2.3.1 right now. Can you check with the SVN trunk, 
please?

Original comment by esizi...@gmail.com on 17 Nov 2010 at 4:47

GoogleCodeExporter commented 9 years ago
I have no way to test the SVN trunk code right now, but I did browse through it 
and noticed that djapian/tests/query.py hasn't been updated since the release 
of 2.3.1 and the BaseIndexerTest and BaseTestCase classes in 
djapian/tests/utils.py also haven't been updated since 2.3.1. Those two classes 
are the ones used in the query_test() suite in djapian/tests/query.py, so 
there's a very good chance the error is still present.

It looks to me like the following two lines at the bottom of 
djapian/tests/query.py should be looking for 3 results to be returned, instead 
of the 2 they are looking for now:

IndexerSearchCharFieldTest = query_test("title:test", 2)
IndexerSearchAliasFieldTest = query_test("subject:test", 2)

Original comment by clevelan...@gmail.com on 17 Nov 2010 at 9:35

GoogleCodeExporter commented 9 years ago
I had a time to look at the issue.

1. all unit tests are passed on my box, including djapian.tests.query.* series

2. IndexerSearchCharFieldTest = query_test("title:test", 2) and 
IndexerSearchAliasFieldTest = query_test("subject:test", 2) tests expects 2 as 
the result because there's no stemming has been enabled for these tests (see 
EntryIndexer in tests/utils.py), so "testing" should not be a hit when 
searching for "test".

I don't see a problem here.

Original comment by esizi...@gmail.com on 19 Nov 2010 at 7:16

GoogleCodeExporter commented 9 years ago
Ah, I see - I have "DJAPIAN_STEMMING_LANG = 'en'" in my settings.py file. So 
that's what's causing the tests to fail on my end? If so, then that makes sense.

So I should be able to get the tests to pass by overriding 
DJAPIAN_STEMMING_LANG to be None through a local settings file before the tests 
are run?

If the answer to both of those questions is yes, then feel free to close this 
issue, as I feel it's been cleared up. Thank you for the help and explanation!

Original comment by clevelan...@gmail.com on 19 Nov 2010 at 2:23

GoogleCodeExporter commented 9 years ago
I actually just checked - placing "DJAPIAN_STEMMING_LANG = None" in a local 
settings file allows the tests to pass. Again, thanks for the explanation!

Perhaps in the future you can add some code to ensure that the tests will pass 
regardless of whether DJAPIAN_STEMMING_LANG is defined or not. Stemming is a 
useful feature for my project, so it would be nice to see the tests pass while 
we're using it.

Original comment by clevelan...@gmail.com on 19 Nov 2010 at 3:18

GoogleCodeExporter commented 9 years ago

Original comment by daevaorn on 19 Nov 2010 at 3:25

GoogleCodeExporter commented 9 years ago
In r375 a temporary fix has been checked in. We might need a better solution 
which would update Indexer._get_stem_language to detect somehow if it is a 
testing session and just return 'none' if that is the case.

Original comment by esizi...@gmail.com on 15 Dec 2010 at 1:59