def test_time_from_string(self):
        self.assertRaises(ParsingError, time_from_string, None)

        fmt = constants.strftime_time_format
        t_1 = datetime.strptime('11:48', fmt).time()
        t_2 = time_from_string('11:48', fmt)

        self.assertEqual(t_1, t_2)
        self.assertRaises(ParsingError, time_from_string, 'am', fmt)
        self.assertRaises(ParsingError, time_from_string, '11:48 am', fmt)
        self.assertRaises(ParsingError, date_from_string, '11:48 AM', fmt)
    def test_time_from_string(self):
        self.assertRaises(ParsingError, time_from_string, None)

        fmt = constants.strftime_time_format
        t_1 = datetime.strptime('11:48', fmt).time()
        t_2 = time_from_string('11:48', fmt)

        self.assertEqual(t_1, t_2)
        self.assertRaises(ParsingError, time_from_string, 'am', fmt)
        self.assertRaises(ParsingError, time_from_string, '11:48 am', fmt)
        self.assertRaises(ParsingError, date_from_string, '11:48 AM', fmt)
Esempio n. 3
0
    def test_time_from_string(self):
        from camelot.view.utils import time_from_string

        result = datetime.time(22, 30)
        self.assertEqual(time_from_string("10:30 PM"), result)
Esempio n. 4
0
 def test_time_from_string(self):
     from camelot.view.utils import time_from_string
     result = datetime.time(22,30)
     self.assertEqual( time_from_string('10:30 PM'), result )