diff options
Diffstat (limited to 'Lib/test/datetimetester.py')
| -rw-r--r-- | Lib/test/datetimetester.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py index ab55476..cf496b4 100644 --- a/Lib/test/datetimetester.py +++ b/Lib/test/datetimetester.py @@ -5,6 +5,7 @@ See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases import sys import pickle +import random import unittest from operator import lt, le, gt, ge, eq, ne, truediv, floordiv, mod @@ -76,8 +77,18 @@ class PicklableFixedOffset(FixedOffset): def __init__(self, offset=None, name=None, dstoffset=None): FixedOffset.__init__(self, offset, name, dstoffset) +class _TZInfo(tzinfo): + def utcoffset(self, datetime_module): + return random.random() + class TestTZInfo(unittest.TestCase): + def test_refcnt_crash_bug_22044(self): + tz1 = _TZInfo() + dt1 = datetime(2014, 7, 21, 11, 32, 3, 0, tz1) + with self.assertRaises(TypeError): + dt1.utcoffset() + def test_non_abstractness(self): # In order to allow subclasses to get pickled, the C implementation # wasn't able to get away with having __init__ raise @@ -619,6 +630,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), |
