unpack_highres_date doctest fails on Python 2.7

Bug #614595 reported by Martin Packman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Low
Jelmer Vernooij

Bug Description

The bzrlib.timestamp.unpack_highres_date doctest outputs a the repr value of a float timestamp, and with Python 2.7 has two fewer digits than the test expects:

    Traceback (most recent call last):
      File "...\python-trunk\lib\doctest.py", line 2153, in runTest
        raise self.failureException(self.format_failure(new.getvalue()))
    AssertionError: Failed doctest test for bzrlib.timestamp.unpack_highres_date
      File ".\bzrlib\timestamp.py", line 66, in unpack_highres_date

    ----------------------------------------------------------------------
    File ".\bzrlib\timestamp.py", line 76, in bzrlib.timestamp.unpack_highres_date
    Failed example:
        unpack_highres_date('Thu 2005-06-30 12:38:52.350850105 -0500')
    Expected:
        (1120153132.3508501, -18000)
    Got:
        (1120153132.35085, -18000)

There have been some changes to float string formatting to make it output the shortest string for the range represented, which I suspect relates to this failure:
<http://bugs.python.org/issue1580>

However, as I can't reproduce this problem outside the doctest I'm uncertain that that is in fact the cause.

Tags: python27
Martin Packman (gz)
Changed in bzr:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
John A Meinel (jameinel) wrote :

doctests should be avoided :). You could do:
- (1120153132.3508501, -18000)
+ 1120153132.350..., -18000)

However, I'll note that inside bzrlib we explicitly truncate timestamps to milliseconds, so that would be a better test.

Martin Packman (gz)
Changed in bzr:
assignee: nobody → Jelmer Vernooij (jelmer)
status: Confirmed → In Progress
Martin Packman (gz)
tags: added: python27
removed: python2.7
Revision history for this message
Martin Packman (gz) wrote :

Doctest conversion to unittest landed in r5581.

Changed in bzr:
milestone: none → 2.3b5
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.