コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
ファイル: test_util.py プロジェクト: nvictor/Camelot
    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)
コード例 #4
0
 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 )