[Python-checkins] python/nondist/sandbox/datetime test_both.py,1.59,1.60
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Wed, 11 Dec 2002 14:09:58 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv17756
Modified Files:
test_both.py
Log Message:
Test that timtz's tzinfo= arg requires a tzinfo subclass instance.
Index: test_both.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_both.py,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** test_both.py 11 Dec 2002 21:47:39 -0000 1.59
--- test_both.py 11 Dec 2002 22:09:56 -0000 1.60
***************
*** 1451,1456 ****
self.assertEqual(t.second, 0)
self.assertEqual(t.microsecond, 0)
! self.assertEqual(t.tzinfo, None)
def test_suite():
--- 1451,1471 ----
self.assertEqual(t.second, 0)
self.assertEqual(t.microsecond, 0)
! self.failUnless(t.tzinfo is None)
+ def test_bad_tzinfo_classes(self):
+ tz = self.theclass
+ self.assertRaises(TypeError, tz, tzinfo=12)
+
+ class NiceTry(object):
+ def __init__(self): pass
+ def utcoffset(self, dt): pass
+ self.assertRaises(TypeError, tz, tzinfo=NiceTry)
+
+ class BetterTry(tzinfo):
+ def __init__(self): pass
+ def utcoffset(self, dt): pass
+ b = BetterTry()
+ t = tz(tzinfo=b)
+ self.failUnless(t.tzinfo is b)
def test_suite():