def test_datetime_from_string(self): self.assertRaises(ParsingError, datetime_from_string, None) fmt = constants.strftime_datetime_format dt_1 = datetime.strptime('19-11-2009 11:48', fmt) dt_2 = datetime_from_string('19-11-2009 11:48', fmt) self.assertEqual(dt_1, dt_2) self.assertRaises(ParsingError, datetime_from_string, '19-11-2009, 11:48', fmt) self.assertRaises(ParsingError, datetime_from_string, '11:48', fmt) self.assertRaises(ParsingError, datetime_from_string, '19-11-2009', fmt)
def test_datetime_from_string(self): from camelot.view.utils import datetime_from_string result = datetime.datetime(2011, 2, 22, 22, 11) self.assertEqual(datetime_from_string("02/22/2011 10:11 PM"), result)
def test_datetime_from_string(self): from camelot.view.utils import datetime_from_string result = datetime.datetime(2011,2,22,22,11) self.assertEqual( datetime_from_string('02/22/2011 10:11 PM'), result )