summaryrefslogtreecommitdiffstats
path: root/Lib/test/datetimetester.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-09-02 17:16:07 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-09-02 17:16:07 (GMT)
commit2ec558739e6bd32365e1a883889f9d5372b35719 (patch)
tree96eebd9fb83fcc59feb0ee478f6cbd0d105a3d29 /Lib/test/datetimetester.py
parent8cbb013553c07e2577d08c7046c0eee70d0c0b66 (diff)
downloadcpython-2ec558739e6bd32365e1a883889f9d5372b35719.zip
cpython-2ec558739e6bd32365e1a883889f9d5372b35719.tar.gz
cpython-2ec558739e6bd32365e1a883889f9d5372b35719.tar.bz2
Issue #23517: datetime.timedelta constructor now rounds microseconds to nearest
with ties going away from zero (ROUND_HALF_UP), as Python 2 and Python older than 3.3, instead of rounding to nearest with ties going to nearest even integer (ROUND_HALF_EVEN).
Diffstat (limited to 'Lib/test/datetimetester.py')
-rw-r--r--Lib/test/datetimetester.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index babeb44..62f5527 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -662,28 +662,24 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
# Single-field rounding.
eq(td(milliseconds=0.4/1000), td(0)) # rounds to 0
eq(td(milliseconds=-0.4/1000), td(0)) # rounds to 0
- eq(td(milliseconds=0.5/1000), td(microseconds=0))
- eq(td(milliseconds=-0.5/1000), td(microseconds=0))
+ eq(td(milliseconds=0.5/1000), td(microseconds=1))
+ eq(td(milliseconds=-0.5/1000), td(microseconds=-1))
eq(td(milliseconds=0.6/1000), td(microseconds=1))
eq(td(milliseconds=-0.6/1000), td(microseconds=-1))
- eq(td(seconds=0.5/10**6), td(microseconds=0))
- eq(td(seconds=-0.5/10**6), td(microseconds=0))
+ eq(td(seconds=0.5/10**6), td(microseconds=1))
+ eq(td(seconds=-0.5/10**6), td(microseconds=-1))
# Rounding due to contributions from more than one field.
us_per_hour = 3600e6
us_per_day = us_per_hour * 24
eq(td(days=.4/us_per_day), td(0))
eq(td(hours=.2/us_per_hour), td(0))
- eq(td(days=.4/us_per_day, hours=.2/us_per_hour), td(microseconds=1))
+ eq(td(days=.4/us_per_day, hours=.2/us_per_hour), td(microseconds=1), td)
eq(td(days=-.4/us_per_day), td(0))
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),