test_stopTestRun_current_time sometimes fails on Pypy

Bug #1523242 reported by Jonathan Lange
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
testtools
Triaged
High
Unassigned

Bug Description

The test expects to run in 0.001s, but it runs in 0.000s. I thought this was a timing bug, but a quick glance at the test makes it look deterministic. Not 100% sure what's going on here—maybe a floating point thing?

======================================================================
FAIL: testtools.tests.test_testresult.TestTextTestResult.test_stopTestRun_current_time
----------------------------------------------------------------------
Traceback (most recent call last):
  File "testtools/tests/test_testresult.py", line 1442, in test_stopTestRun_current_time
    DocTestMatches("... in 0.001s\n...", doctest.ELLIPSIS))
  File "testtools/testcase.py", line 435, in assertThat
    raise mismatch_error
testtools.matchers._impl.MismatchError: Expected:
    ... in 0.001s
    ...
Got:
    <BLANKLINE>
    Ran 1 test in 0.000s
    OK
Ran 1196 tests in 0.987s
FAILED (failures=1)

Revision history for this message
Jonathan Lange (jml) wrote :
Revision history for this message
Jonathan Lange (jml) wrote : Re: [Bug 1523242] Re: test_stopTestRun_current_time sometimes fails on Pypy

There's some code around this in TextTestResult:

    def _delta_to_float(self, a_timedelta, precision):
        # This calls ceiling to ensure that the most pessimistic view of
time
        # taken is shown (rather than leaving it to the Python %f operator
        # to decide whether to round/floor/ceiling. This was added when we
        # had pyp3 test failures that suggest a floor was happening.
        shift = 10 ** precision
        return math.ceil(
            (a_timedelta.days * 86400.0 + a_timedelta.seconds +
             a_timedelta.microseconds / 1000000.0) * shift) / shift

...
    def stopTestRun(self):
        ...
        self.stream.write(
            "\nRan %d test%s in %.3fs\n" % (
                self.testsRun, plural,
                self._delta_to_float(stop - self.__start, 4)))
...

On Sun, 6 Dec 2015 at 15:00 Jonathan Lange <email address hidden> wrote:

> https://travis-ci.org/jml/testtools/jobs/95177983
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1523242
>
> Title:
> test_stopTestRun_current_time sometimes fails on Pypy
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/testtools/+bug/1523242/+subscriptions
>

Jonathan Lange (jml)
Changed in testtools:
status: New → Triaged
importance: Undecided → High
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.