[Django] #30967: Test suite fails on Postgres 12

10 views
Skip to first unread message

Django

unread,
Nov 8, 2019, 3:16:16 PM11/8/19
to django-...@googlegroups.com
#30967: Test suite fails on Postgres 12
--------------------------------------------+--------------------------
Reporter: Hannes Ljungberg | Owner: (none)
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Keywords: tests
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+--------------------------
The test suite is broken on Postgres 12.

`postgres_tests.test_trigram.TrigramTest.test_trigram_similarity` fails
with the following output:

{{{
======================================================================
FAIL [0.013s]: test_trigram_similarity
(postgres_tests.test_trigram.TrigramTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tests/django/tests/postgres_tests/test_trigram.py", line 35, in
test_trigram_similarity
ordered=True,
File "/tests/django/django/test/testcases.py", line 1043, in
assertQuerysetEqual
return self.assertEqual(list(items), values, msg=msg)
AssertionError: Lists differ: [('Cat sat on mat.', 0.625), ('Dog sat on
rug.', 0.33333334)] != [('Cat sat on mat.', 0.625), ('Dog sat on rug.',
0.333333)]

First differing element 1:
('Dog sat on rug.', 0.33333334)
('Dog sat on rug.', 0.333333)

- [('Cat sat on mat.', 0.625), ('Dog sat on rug.', 0.33333334)]
? --

+ [('Cat sat on mat.', 0.625), ('Dog sat on rug.', 0.333333)]
}}}

`postgres_tests.test_trigram.TrigramTest.test_trigram_similarity_alternate`
fails with the following output:
{{{
======================================================================
FAIL [0.008s]: test_trigram_similarity_alternate
(postgres_tests.test_trigram.TrigramTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tests/django/tests/postgres_tests/test_trigram.py", line 45, in
test_trigram_similarity_alternate
ordered=True,
File "/tests/django/django/test/testcases.py", line 1043, in
assertQuerysetEqual
return self.assertEqual(list(items), values, msg=msg)
AssertionError: Lists differ: [('Cat sat on mat.', 0.375), ('Dog sat on
rug.', 0.6666666)] != [('Cat sat on mat.', 0.375), ('Dog sat on rug.',
0.666667)]

First differing element 1:
('Dog sat on rug.', 0.6666666)
('Dog sat on rug.', 0.666667)

- [('Cat sat on mat.', 0.375), ('Dog sat on rug.', 0.6666666)]
? ^^

+ [('Cat sat on mat.', 0.375), ('Dog sat on rug.', 0.666667)]
? ^
}}}

This is caused by changes made to how floats are rounded in Postgres 12:

Improve performance by using a new algorithm for output of real and
double precision values (Andrew Gierth)
Previously, displayed floating-point values were rounded to 6 (for real)
or 15 (for double precision) digits by default, adjusted by the value of
extra_float_digits. Now, whenever extra_float_digits is more than zero (as
it now is by default), only the minimum number of digits required to
preserve the exact binary value are output. The behavior is the same as
before when extra_float_digits is set to zero or less.
Also, formatting of floating-point exponents is now uniform across
platforms: two digits are used unless three are necessary. In previous
releases, Windows builds always printed three digits.

https://www.postgresql.org/docs/release/12.0/

To have consistent behaviour on all Postgres versions my suggestion is to
set `extra_float_digits` to 0 on these tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/30967>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 8, 2019, 3:16:23 PM11/8/19
to django-...@googlegroups.com
#30967: Test suite fails on Postgres 12
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg

Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:

Keywords: tests | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hannes Ljungberg):

* owner: (none) => Hannes Ljungberg


--
Ticket URL: <https://code.djangoproject.com/ticket/30967#comment:1>

Django

unread,
Nov 8, 2019, 3:22:54 PM11/8/19
to django-...@googlegroups.com
#30967: Test suite fails on Postgres 12
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:

Keywords: tests | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Hannes Ljungberg):

PR: https://github.com/django/django/pull/12048

--
Ticket URL: <https://code.djangoproject.com/ticket/30967#comment:2>

Django

unread,
Nov 8, 2019, 3:33:14 PM11/8/19
to django-...@googlegroups.com
#30967: Test suite fails on Postgres 12
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:

Keywords: tests | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hannes Ljungberg):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30967#comment:3>

Django

unread,
Nov 8, 2019, 3:42:00 PM11/8/19
to django-...@googlegroups.com
#30967: Test suite fails on Postgres 12
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: Bug | Status: assigned
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Unreviewed => Accepted


Comment:

Failed tests:
- `postgres_tests.test_trigram.TrigramTest.test_trigram_similarity`
-
`postgres_tests.test_trigram.TrigramTest.test_trigram_similarity_alternate`
-
`postgres_tests.test_trigram.TrigramTextFieldTest.test_trigram_similarity`
-
`postgres_tests.test_trigram.TrigramTextFieldTest.test_trigram_similarity_alternate`

--
Ticket URL: <https://code.djangoproject.com/ticket/30967#comment:4>

Django

unread,
Nov 11, 2019, 7:31:12 AM11/11/19
to django-...@googlegroups.com
#30967: Test suite fails on Postgres 12
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: Bug | Status: closed
Component: contrib.postgres | Version: master
Severity: Normal | Resolution: fixed

Keywords: tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"8d3f43f7a9dc0b83dd9ac82ac0270bfee88ed51f" 8d3f43f7]:
{{{
#!CommitTicketReference repository=""
revision="8d3f43f7a9dc0b83dd9ac82ac0270bfee88ed51f"
[3.0.x] Fixed #30967 -- Fixed TrigramTest failures on PostgreSQL 12+.

Backport of 6e2f05b2e33a6c80c7a411ce76af7b5a08acb835 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30967#comment:5>

Django

unread,
Nov 11, 2019, 7:31:13 AM11/11/19
to django-...@googlegroups.com
#30967: Test suite fails on Postgres 12
-------------------------------------+-------------------------------------
Reporter: Hannes Ljungberg | Owner: Hannes
| Ljungberg
Type: Bug | Status: closed
Component: contrib.postgres | Version: master

Severity: Normal | Resolution: fixed
Keywords: tests | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"6e2f05b2e33a6c80c7a411ce76af7b5a08acb835" 6e2f05b2]:
{{{
#!CommitTicketReference repository=""
revision="6e2f05b2e33a6c80c7a411ce76af7b5a08acb835"


Fixed #30967 -- Fixed TrigramTest failures on PostgreSQL 12+.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30967#comment:6>

Reply all
Reply to author
Forward
0 new messages