Fixed #31601 -- Fixed SearchHeadlineTests on PostgresSQL 9.6.18+, 10.13+, 11.8+, and 12.3+.

This commit is contained in:
Hannes Ljungberg 2020-05-17 23:20:16 +02:00 committed by Mariusz Felisiak
parent 4029bcd6b2
commit 952afc166c
1 changed files with 9 additions and 7 deletions

View File

@ -31,7 +31,7 @@ class GrailTestData:
'Bravely bold Sir Robin, rode forth from Camelot. ' 'Bravely bold Sir Robin, rode forth from Camelot. '
'He was not afraid to die, o Brave Sir Robin. ' 'He was not afraid to die, o Brave Sir Robin. '
'He was not at all afraid to be killed in nasty ways. ' 'He was not at all afraid to be killed in nasty ways. '
'Brave, brave, brave, brave Sir Robin!' 'Brave, brave, brave, brave Sir Robin'
), ),
( (
'He was not in the least bit scared to be mashed into a pulp, ' 'He was not in the least bit scared to be mashed into a pulp, '
@ -578,7 +578,7 @@ class SearchHeadlineTests(GrailTestData, PostgreSQLTestCase):
self.assertEqual( self.assertEqual(
searched.headline, searched.headline,
'Robin. He was not at all afraid to be <b>killed</b> in nasty ' 'Robin. He was not at all afraid to be <b>killed</b> in nasty '
'ways. Brave, brave, brave, brave Sir Robin!', 'ways. Brave, brave, brave, brave Sir Robin',
) )
def test_headline_with_config(self): def test_headline_with_config(self):
@ -641,13 +641,15 @@ class SearchHeadlineTests(GrailTestData, PostgreSQLTestCase):
searched = Line.objects.annotate( searched = Line.objects.annotate(
headline=SearchHeadline( headline=SearchHeadline(
'dialogue', 'dialogue',
SearchQuery('brave sir robin', config='english'), SearchQuery('Camelot', config='english'),
short_word=6, short_word=5,
min_words=8,
), ),
).get(pk=self.verse0.pk) ).get(pk=self.verse0.pk)
self.assertIs(searched.headline.endswith( self.assertEqual(searched.headline, (
'<b>Brave</b>, <b>brave</b>, <b>brave</b>, <b>brave</b> <b>Sir</b>' '<b>Camelot</b>. He was not afraid to die, o Brave Sir Robin. He '
), True) 'was not at all afraid'
))
def test_headline_fragments_words_options(self): def test_headline_fragments_words_options(self):
searched = Line.objects.annotate( searched = Line.objects.annotate(