#18964 closed Bug (fixed)

defaultfilters test passes unexpectedly under Python 3

Reported by: russellm Owned by: aaugustin
Component: Uncategorized Version: master
Severity: Release blocker Keywords: python3
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


defaultfilters.DefaultFiltersTests.test_floatformat_fail is currently marked as an expected failure; and under Python 2, it does fail.

Under Python 3 (at least, with Python 3.2.3 64 bit under OSX), the test passes.

It's entirely possible that the resolution is "don't worry about it" - after all, there are worse problems than an unexpected test pass. However, since it is an oddity in test suite results that may have gone unnoticed (since 'unexpected pass' would be easy to miss in test suite results), I'm marking this as a release blocker.

Attachments (0)

Change History (4)

comment:1 Changed 19 months ago by russellm

  • Keywords python3 added
  • Version changed from 1.4 to master

comment:2 Changed 18 months ago by aaugustin

  • Owner changed from nobody to aaugustin

comment:3 Changed 18 months ago by aaugustin

The test that unexpectedly passes is:

self.assertEqual(floatformat(1.00000000000000015, 16), '1.0000000000000002')

Under Python 2, it returns '1.0000000000000000'.

The explanation is pretty simple.

The first step of the floatformat template filter is to coerce its input as text, and this step introduces the difference between Python 2 and Python 3.

% python2.6
>>> 1.00000000000000015
>>> str(_)
% python3.2
>>> 1.00000000000000015
>>> str(_)

I think it's related to this paragraph of Python 3.1's release notes:

Python now uses David Gay’s algorithm for finding the shortest floating point representation that doesn’t change its value.

Arguably, this is a bug in Python 2 that was fixed in Python 3. I'm going to mark the test as an expected failure only on Python 2.

comment:4 Changed 18 months ago by Aymeric Augustin <aymeric.augustin@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 8d7e526229c27567860f7479dbce15d245742feb:

[1.5.x] Fixed #18964 -- floatformat test passes under py3k

Thanks Russell for the report.

Backport of b4420d9 from master.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.