Пример #1
0
    def test_dates(self):
        """Check if it converts some dates to datetime objects"""

        date = str_to_datetime('2001-12-01')
        self.assertIsInstance(date, datetime.datetime)
        self.assertEqual(date, datetime.datetime(2001, 12, 1))

        date = str_to_datetime('13-01-2001')
        self.assertIsInstance(date, datetime.datetime)
        self.assertEqual(date, datetime.datetime(2001, 1, 13))

        date = str_to_datetime('12-01-01')
        self.assertIsInstance(date, datetime.datetime)
        self.assertEqual(date, datetime.datetime(2001, 12, 1))

        date = str_to_datetime('2001-12-01 23:15:32')
        self.assertIsInstance(date, datetime.datetime)
        self.assertEqual(date, datetime.datetime(2001, 12, 1, 23, 15, 32))
Пример #2
0
    def test_dates(self):
        """Check if it converts some dates to datetime objects"""

        date = str_to_datetime('2001-12-01')
        self.assertIsInstance(date, datetime.datetime)
        self.assertEqual(date, datetime.datetime(2001, 12, 1))

        date = str_to_datetime('13-01-2001')
        self.assertIsInstance(date, datetime.datetime)
        self.assertEqual(date, datetime.datetime(2001, 1, 13))

        date = str_to_datetime('12-01-01')
        self.assertIsInstance(date, datetime.datetime)
        self.assertEqual(date, datetime.datetime(2001, 12, 1))

        date = str_to_datetime('2001-12-01 23:15:32')
        self.assertIsInstance(date, datetime.datetime)
        self.assertEqual(date, datetime.datetime(2001, 12, 1, 23, 15, 32))
Пример #3
0
    def test_empty_string(self):
        """Check if it returns None when giving empty strings"""

        date = str_to_datetime('')
        self.assertEqual(date, None)
Пример #4
0
    def test_none_string(self):
        """Check if it returns None when giving None objects"""

        date = str_to_datetime(None)
        self.assertEqual(date, None)
Пример #5
0
    def test_empty_string(self):
        """Check if it returns None when giving empty strings"""

        date = str_to_datetime('')
        self.assertEqual(date, None)
Пример #6
0
    def test_none_string(self):
        """Check if it returns None when giving None objects"""

        date = str_to_datetime(None)
        self.assertEqual(date, None)