summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2013-08-04 18:51:35 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2013-08-04 18:51:35 (GMT)
commit790d269d393fe625614db5cc8fe8ad0d4029253d (patch)
tree98bf336596290e65a119f014c75a419143ad3744 /Lib
parent5e5a8230c206e5762b5d4c0708189422c1b1f3b1 (diff)
downloadcpython-790d269d393fe625614db5cc8fe8ad0d4029253d.zip
cpython-790d269d393fe625614db5cc8fe8ad0d4029253d.tar.gz
cpython-790d269d393fe625614db5cc8fe8ad0d4029253d.tar.bz2
Fixes #8860: Round half-microseconds to even in the timedelta constructor.
(Original patch by Mark Dickinson.)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/datetimetester.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 931ef6f..e08b2dc 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -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),