[Python-checkins] CVS: python/nondist/sandbox/datetime test_cdatetime.py,1.1,1.2
Fred L. Drake
fdrake@users.sourceforge.net
Tue, 05 Mar 2002 20:36:29 -0800
Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory usw-pr-cvs1:/tmp/cvs-serv6342
Modified Files:
test_cdatetime.py
Log Message:
Add test that retrieves the basic attributes from the datetime instance
which actually checks that the bit-shifting accessors do the right thing.
Add the test of the isoformat() method now that we have it.
Index: test_cdatetime.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/test_cdatetime.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test_cdatetime.py 4 Mar 2002 20:44:19 -0000 1.1
--- test_cdatetime.py 6 Mar 2002 04:36:26 -0000 1.2
***************
*** 11,16 ****
class TestDateTime(unittest.TestCase):
def test_basic_attributes(self):
! dt = datetime(2002, 3, 1, 12, 0, 0)
self.assertEqual(dt.year, 2002)
self.assertEqual(dt.month, 3)
--- 11,18 ----
class TestDateTime(unittest.TestCase):
+ theclass = datetime
+
def test_basic_attributes(self):
! dt = self.theclass(2002, 3, 1, 12, 0)
self.assertEqual(dt.year, 2002)
self.assertEqual(dt.month, 3)
***************
*** 20,23 ****
--- 22,44 ----
self.assertEqual(dt.second, 0)
self.assertEqual(dt.microsecond, 0)
+
+ def test_basic_attributes_nonzero(self):
+ # Make sure all attributes are non-zero so bugs in
+ # bit-shifting access show up.
+ dt = self.theclass(2002, 3, 1, 12, 59, 59, 8000)
+ self.assertEqual(dt.year, 2002)
+ self.assertEqual(dt.month, 3)
+ self.assertEqual(dt.day, 1)
+ self.assertEqual(dt.hour, 12)
+ self.assertEqual(dt.minute, 59)
+ self.assertEqual(dt.second, 59)
+ self.assertEqual(dt.microsecond, 8000)
+
+ def test_isoformat(self):
+ t = self.theclass(2, 3, 2, 4, 5, 1, 123)
+ self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123")
+ self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123")
+ self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123")
+
def test_suite():