Fixes #8860: Round half-microseconds to even in the timedelta constructor.

(Original patch by Mark Dickinson.)
This commit is contained in:
Alexander Belopolsky 2013-08-04 14:51:35 -04:00
parent 5e5a8230c2
commit 790d269d39
4 changed files with 42 additions and 22 deletions

View file

@ -619,6 +619,10 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
eq(td(hours=-.2/us_per_hour), td(0))
eq(td(days=-.4/us_per_day, hours=-.2/us_per_hour), td(microseconds=-1))
# Test for a patch in Issue 8860
eq(td(microseconds=0.5), 0.5*td(microseconds=1.0))
eq(td(microseconds=0.5)//td.resolution, 0.5*td.resolution//td.resolution)
def test_massive_normalization(self):
td = timedelta(microseconds=-1)
self.assertEqual((td.days, td.seconds, td.microseconds),