summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_datetime.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_datetime.py')
-rw-r--r--Lib/test/test_datetime.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index 7d503e0..0b9597a 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -2266,7 +2266,7 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase):
# Try with and without naming the keyword.
off42 = FixedOffset(42, "42")
another = meth(ts, off42)
- again = meth(ts, tzinfo=off42)
+ again = meth(ts, tz=off42)
self.failUnless(another.tzinfo is again.tzinfo)
self.assertEqual(another.utcoffset(), timedelta(minutes=42))
# Bad argument with and w/o naming the keyword.
@@ -2279,6 +2279,20 @@ class TestDateTimeTZ(TestDateTime, TZInfoBase):
# Too few args.
self.assertRaises(TypeError, meth)
+ # Try to make sure tz= actually does some conversion.
+ timestamp = 1000000000 # 2001-09-09 01:46:40 UTC, give or take
+ utc = FixedOffset(0, "utc", 0)
+ expected = datetime(2001, 9, 9, 1, 46, 40)
+ got = datetime.utcfromtimestamp(timestamp)
+ # We don't support leap seconds, but maybe the platfrom insists
+ # on using them, so don't demand exact equality).
+ self.failUnless(abs(got - expected) < timedelta(minutes=1))
+
+ est = FixedOffset(-5*60, "est", 0)
+ expected -= timedelta(hours=5)
+ got = datetime.fromtimestamp(timestamp, est).replace(tzinfo=None)
+ self.failUnless(abs(got - expected) < timedelta(minutes=1))
+
def test_tzinfo_utcnow(self):
meth = self.theclass.utcnow
# Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).