summaryrefslogtreecommitdiff
path: root/Lib/test/test_datetime.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-07-05 15:26:36 +0000
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-07-05 15:26:36 +0000
commitf5c7bc841bc08128be92ec162926f7c56e1da878 (patch)
treefc06c230fcf2c91d4d9ce5274e3e633fa4deae8f /Lib/test/test_datetime.py
parent74ceac2306d69f5f6e58dd92177be6ea28c155ab (diff)
downloadcpython-git-f5c7bc841bc08128be92ec162926f7c56e1da878.tar.gz
Merged revisions 82578 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82578 | alexander.belopolsky | 2010-07-05 11:05:33 -0400 (Mon, 05 Jul 2010) | 1 line Added more tests for utctimetuple() ........
Diffstat (limited to 'Lib/test/test_datetime.py')
-rw-r--r--Lib/test/test_datetime.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index 93df698b5f..5422fdf02b 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -2738,7 +2738,7 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
def test_utctimetuple(self):
class DST(tzinfo):
- def __init__(self, dstvalue):
+ def __init__(self, dstvalue=0):
if isinstance(dstvalue, int):
dstvalue = timedelta(minutes=dstvalue)
self.dstvalue = dstvalue
@@ -2772,6 +2772,25 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
self.assertEqual(d.toordinal() - date(1, 1, 1).toordinal() + 1,
t.tm_yday)
self.assertEqual(0, t.tm_isdst)
+ # For naive datetime, utctimetuple == timetuple except for isdst
+ d = cls(1, 2, 3, 10, 20, 30, 40)
+ t = d.utctimetuple()
+ self.assertEqual(t[:-1], d.timetuple()[:-1])
+ self.assertEqual(0, t.tm_isdst)
+ # Same if utcoffset is None
+ class NOFS(DST):
+ def utcoffset(self, dt):
+ return None
+ d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=NOFS())
+ t = d.utctimetuple()
+ self.assertEqual(t[:-1], d.timetuple()[:-1])
+ self.assertEqual(0, t.tm_isdst)
+ # Check that bad tzinfo is detected
+ class BOFS(DST):
+ def utcoffset(self, dt):
+ return "EST"
+ d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=BOFS())
+ self.assertRaises(TypeError, d.utctimetuple)
# At the edges, UTC adjustment can normalize into years out-of-range
# for a datetime object. Ensure that a correct timetuple is