MCPcopy Create free account
hub / github.com/dateutil/dateutil / ParserTest

Class ParserTest

tests/test_parser.py:408–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406
407
408class ParserTest(unittest.TestCase):
409
410 @classmethod
411 def setup_class(cls):
412 cls.tzinfos = {"BRST": -10800}
413 cls.brsttz = tzoffset("BRST", -10800)
414 cls.default = datetime(2003, 9, 25)
415
416 # Parser should be able to handle bytestring and unicode
417 cls.uni_str = '2014-05-01 08:00:00'
418 cls.str_str = cls.uni_str.encode()
419
420 def testParserParseStr(self):
421 from dateutil.parser import parser
422
423 assert parser().parse(self.str_str) == parser().parse(self.uni_str)
424
425 def testParseUnicodeWords(self):
426
427 class rus_parserinfo(parserinfo):
428 MONTHS = [("янв", "Январь"),
429 ("фев", "Февраль"),
430 ("мар", "Март"),
431 ("апр", "Апрель"),
432 ("май", "Май"),
433 ("июн", "Июнь"),
434 ("июл", "Июль"),
435 ("авг", "Август"),
436 ("сен", "Сентябрь"),
437 ("окт", "Октябрь"),
438 ("ноя", "Ноябрь"),
439 ("дек", "Декабрь")]
440
441 expected = datetime(2015, 9, 10, 10, 20)
442 res = parse('10 Сентябрь 2015 10:20', parserinfo=rus_parserinfo())
443 assert res == expected
444
445 def testParseWithNulls(self):
446 # This relies on the from __future__ import unicode_literals, because
447 # explicitly specifying a unicode literal is a syntax error in Py 3.2
448 # May want to switch to u'...' if we ever drop Python 3.2 support.
449 pstring = '\x00\x00August 29, 1924'
450
451 assert parse(pstring) == datetime(1924, 8, 29)
452
453 def testDateCommandFormat(self):
454 self.assertEqual(parse("Thu Sep 25 10:36:28 BRST 2003",
455 tzinfos=self.tzinfos),
456 datetime(2003, 9, 25, 10, 36, 28,
457 tzinfo=self.brsttz))
458
459 def testDateCommandFormatReversed(self):
460 self.assertEqual(parse("2003 10:36:28 BRST 25 Sep Thu",
461 tzinfos=self.tzinfos),
462 datetime(2003, 9, 25, 10, 36, 28,
463 tzinfo=self.brsttz))
464
465 def testDateCommandFormatWithLong(self):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected