| 404 | |
| 405 | |
| 406 | class ParserTest(unittest.TestCase): |
| 407 | |
| 408 | @classmethod |
| 409 | def setup_class(cls): |
| 410 | cls.tzinfos = {"BRST": -10800} |
| 411 | cls.brsttz = tzoffset("BRST", -10800) |
| 412 | cls.default = datetime(2003, 9, 25) |
| 413 | |
| 414 | # Parser should be able to handle bytestring and unicode |
| 415 | cls.uni_str = '2014-05-01 08:00:00' |
| 416 | cls.str_str = cls.uni_str.encode() |
| 417 | |
| 418 | def testParserParseStr(self): |
| 419 | from dateutil.parser import parser |
| 420 | |
| 421 | assert parser().parse(self.str_str) == parser().parse(self.uni_str) |
| 422 | |
| 423 | def testParseUnicodeWords(self): |
| 424 | |
| 425 | class rus_parserinfo(parserinfo): |
| 426 | MONTHS = [("янв", "Январь"), |
| 427 | ("фев", "Февраль"), |
| 428 | ("мар", "Март"), |
| 429 | ("апр", "Апрель"), |
| 430 | ("май", "Май"), |
| 431 | ("июн", "Июнь"), |
| 432 | ("июл", "Июль"), |
| 433 | ("авг", "Август"), |
| 434 | ("сен", "Сентябрь"), |
| 435 | ("окт", "Октябрь"), |
| 436 | ("ноя", "Ноябрь"), |
| 437 | ("дек", "Декабрь")] |
| 438 | |
| 439 | expected = datetime(2015, 9, 10, 10, 20) |
| 440 | res = parse('10 Сентябрь 2015 10:20', parserinfo=rus_parserinfo()) |
| 441 | assert res == expected |
| 442 | |
| 443 | def testParseWithNulls(self): |
| 444 | pstring = '\x00\x00August 29, 1924' |
| 445 | |
| 446 | assert parse(pstring) == datetime(1924, 8, 29) |
| 447 | |
| 448 | def testDateCommandFormat(self): |
| 449 | self.assertEqual(parse("Thu Sep 25 10:36:28 BRST 2003", |
| 450 | tzinfos=self.tzinfos), |
| 451 | datetime(2003, 9, 25, 10, 36, 28, |
| 452 | tzinfo=self.brsttz)) |
| 453 | |
| 454 | def testDateCommandFormatReversed(self): |
| 455 | self.assertEqual(parse("2003 10:36:28 BRST 25 Sep Thu", |
| 456 | tzinfos=self.tzinfos), |
| 457 | datetime(2003, 9, 25, 10, 36, 28, |
| 458 | tzinfo=self.brsttz)) |
| 459 | |
| 460 | def testISOFormatStrip2(self): |
| 461 | self.assertEqual(parse("2003-09-25T10:49:41+03:00"), |
| 462 | datetime(2003, 9, 25, 10, 49, 41, |
| 463 | tzinfo=tzoffset(None, 10800))) |
nothing calls this directly
no outgoing calls
no test coverage detected