def test_parse_duration_hms(self): self.assertEqual(parse_duration('2345s'), 2345) self.assertEqual(parse_duration('3m'), 180) self.assertEqual(parse_duration('1h'), 3600) self.assertEqual(parse_duration('3h5m2s'), 11102) self.assertEqual(parse_duration('3 h 5 m 2 s'), 11102) self.assertEqual(parse_duration('1h 1m 1s'), 3661) self.assertEqual(parse_duration('1h 1m1s'), 3661)
def test_parse_duration_largeinput(self): self.assertEqual(parse_duration('12345678912345678912481639176'), 12345678912345678912481639176)
def test_parse_duration_noinput(self): self.assertEqual(parse_duration(''), 0) self.assertEqual(parse_duration('Unknown'), None) self.assertEqual(parse_duration('whatgoeshere'), None)
def test_parse_duration_hoursminutesseconds(self): self.assertEqual(parse_duration('3 hours 5 minutes 2 seconds'), 11102) self.assertEqual(parse_duration('1hour1minute1second'), 3661) self.assertEqual(parse_duration('3hours 5minutes 2seconds'), 11102) self.assertEqual(parse_duration('3hours 5minutes2seconds'), 11102)
def test_parse_duration(self): self.assertEqual(parse_duration(None), None) self.assertEqual(parse_duration(False), None) self.assertEqual(parse_duration('invalid'), None) self.assertEqual(parse_duration('1'), 1) self.assertEqual(parse_duration('1337:12'), 80232) self.assertEqual(parse_duration('9:12:43'), 33163) self.assertEqual(parse_duration('12:00'), 720) self.assertEqual(parse_duration('00:01:01'), 61) self.assertEqual(parse_duration('x:y'), None) self.assertEqual(parse_duration('3h11m53s'), 11513) self.assertEqual(parse_duration('3h 11m 53s'), 11513) self.assertEqual(parse_duration('3 hours 11 minutes 53 seconds'), 11513) self.assertEqual(parse_duration('3 hours 11 mins 53 secs'), 11513) self.assertEqual(parse_duration('62m45s'), 3765) self.assertEqual(parse_duration('6m59s'), 419) self.assertEqual(parse_duration('49s'), 49) self.assertEqual(parse_duration('0h0m0s'), 0) self.assertEqual(parse_duration('0m0s'), 0) self.assertEqual(parse_duration('0s'), 0) self.assertEqual(parse_duration('01:02:03.05'), 3723.05) self.assertEqual(parse_duration('T30M38S'), 1838) self.assertEqual(parse_duration('5 s'), 5) self.assertEqual(parse_duration('3 min'), 180) self.assertEqual(parse_duration('2.5 hours'), 9000) self.assertEqual(parse_duration('02:03:04'), 7384) self.assertEqual(parse_duration('01:02:03:04'), 93784) self.assertEqual(parse_duration('1 hour 3 minutes'), 3780) self.assertEqual(parse_duration('87 Min.'), 5220) self.assertEqual(parse_duration('PT1H0.040S'), 3600.04)
def test_parse_duration_number_format(self): self.assertEqual(parse_duration('14243'), 14243) self.assertEqual(parse_duration('00:07:00'), 420) self.assertEqual(parse_duration('09:00'), 540) self.assertEqual(parse_duration('09:00:00'), 32400)
def test_parse_duration(self): self.assertEqual(parse_duration(None), None) self.assertEqual(parse_duration(False), None) self.assertEqual(parse_duration('invalid'), None) self.assertEqual(parse_duration('1'), 1) self.assertEqual(parse_duration('1337:12'), 80232) self.assertEqual(parse_duration('9:12:43'), 33163) self.assertEqual(parse_duration('12:00'), 720) self.assertEqual(parse_duration('00:01:01'), 61) self.assertEqual(parse_duration('x:y'), None) self.assertEqual(parse_duration('3h11m53s'), 11513) self.assertEqual(parse_duration('3h 11m 53s'), 11513) self.assertEqual(parse_duration('3 hours 11 minutes 53 seconds'), 11513) self.assertEqual(parse_duration('3 hours 11 mins 53 secs'), 11513) self.assertEqual(parse_duration('62m45s'), 3765) self.assertEqual(parse_duration('6m59s'), 419) self.assertEqual(parse_duration('49s'), 49) self.assertEqual(parse_duration('0h0m0s'), 0) self.assertEqual(parse_duration('0m0s'), 0) self.assertEqual(parse_duration('0s'), 0) self.assertEqual(parse_duration('01:02:03.05'), 3723.05) self.assertEqual(parse_duration('T30M38S'), 1838) self.assertEqual(parse_duration('5 s'), 5) self.assertEqual(parse_duration('3 min'), 180) self.assertEqual(parse_duration('2.5 hours'), 9000) self.assertEqual(parse_duration('02:03:04'), 7384) self.assertEqual(parse_duration('01:02:03:04'), 93784) self.assertEqual(parse_duration('1 hour 3 minutes'), 3780) self.assertEqual(parse_duration('87 Min.'), 5220)
def test_parse_duration(self): self.assertEqual(parse_duration(None), None) self.assertEqual(parse_duration('1'), 1) self.assertEqual(parse_duration('1337:12'), 80232) self.assertEqual(parse_duration('9:12:43'), 33163) self.assertEqual(parse_duration('12:00'), 720) self.assertEqual(parse_duration('00:01:01'), 61) self.assertEqual(parse_duration('x:y'), None) self.assertEqual(parse_duration('3h11m53s'), 11513) self.assertEqual(parse_duration('62m45s'), 3765) self.assertEqual(parse_duration('6m59s'), 419) self.assertEqual(parse_duration('49s'), 49) self.assertEqual(parse_duration('0h0m0s'), 0) self.assertEqual(parse_duration('0m0s'), 0) self.assertEqual(parse_duration('0s'), 0)
def test_parse_duration(self): self.assertEqual(parse_duration(None), None) self.assertEqual(parse_duration('1'), 1) self.assertEqual(parse_duration('1337:12'), 80232) self.assertEqual(parse_duration('9:12:43'), 33163) self.assertEqual(parse_duration('x:y'), None)
def test_parse_duration(self): self.assertEqual(parse_duration(None), None) self.assertEqual(parse_duration(False), None) self.assertEqual(parse_duration("invalid"), None) self.assertEqual(parse_duration("1"), 1) self.assertEqual(parse_duration("1337:12"), 80232) self.assertEqual(parse_duration("9:12:43"), 33163) self.assertEqual(parse_duration("12:00"), 720) self.assertEqual(parse_duration("00:01:01"), 61) self.assertEqual(parse_duration("x:y"), None) self.assertEqual(parse_duration("3h11m53s"), 11513) self.assertEqual(parse_duration("3h 11m 53s"), 11513) self.assertEqual(parse_duration("3 hours 11 minutes 53 seconds"), 11513) self.assertEqual(parse_duration("3 hours 11 mins 53 secs"), 11513) self.assertEqual(parse_duration("62m45s"), 3765) self.assertEqual(parse_duration("6m59s"), 419) self.assertEqual(parse_duration("49s"), 49) self.assertEqual(parse_duration("0h0m0s"), 0) self.assertEqual(parse_duration("0m0s"), 0) self.assertEqual(parse_duration("0s"), 0) self.assertEqual(parse_duration("01:02:03.05"), 3723.05) self.assertEqual(parse_duration("T30M38S"), 1838) self.assertEqual(parse_duration("5 s"), 5) self.assertEqual(parse_duration("3 min"), 180) self.assertEqual(parse_duration("2.5 hours"), 9000) self.assertEqual(parse_duration("02:03:04"), 7384) self.assertEqual(parse_duration("01:02:03:04"), 93784) self.assertEqual(parse_duration("1 hour 3 minutes"), 3780) self.assertEqual(parse_duration("87 Min."), 5220) self.assertEqual(parse_duration("PT1H0.040S"), 3600.04)
def test_parse_duration(self): self.assertEqual(parse_duration(None), None) self.assertEqual(parse_duration("1"), 1) self.assertEqual(parse_duration("1337:12"), 80232) self.assertEqual(parse_duration("9:12:43"), 33163) self.assertEqual(parse_duration("12:00"), 720) self.assertEqual(parse_duration("00:01:01"), 61) self.assertEqual(parse_duration("x:y"), None) self.assertEqual(parse_duration("3h11m53s"), 11513) self.assertEqual(parse_duration("3h 11m 53s"), 11513) self.assertEqual(parse_duration("3 hours 11 minutes 53 seconds"), 11513) self.assertEqual(parse_duration("3 hours 11 mins 53 secs"), 11513) self.assertEqual(parse_duration("62m45s"), 3765) self.assertEqual(parse_duration("6m59s"), 419) self.assertEqual(parse_duration("49s"), 49) self.assertEqual(parse_duration("0h0m0s"), 0) self.assertEqual(parse_duration("0m0s"), 0) self.assertEqual(parse_duration("0s"), 0) self.assertEqual(parse_duration("01:02:03.05"), 3723.05)
def test_parse_duration(self): self.assertEqual(parse_duration(None), None) self.assertEqual(parse_duration('1'), 1) self.assertEqual(parse_duration('1337:12'), 80232) self.assertEqual(parse_duration('9:12:43'), 33163) self.assertEqual(parse_duration('12:00'), 720) self.assertEqual(parse_duration('00:01:01'), 61) self.assertEqual(parse_duration('x:y'), None) self.assertEqual(parse_duration('3h11m53s'), 11513) self.assertEqual(parse_duration('3h 11m 53s'), 11513) self.assertEqual(parse_duration('3 hours 11 minutes 53 seconds'), 11513) self.assertEqual(parse_duration('3 hours 11 mins 53 secs'), 11513) self.assertEqual(parse_duration('62m45s'), 3765) self.assertEqual(parse_duration('6m59s'), 419) self.assertEqual(parse_duration('49s'), 49) self.assertEqual(parse_duration('0h0m0s'), 0) self.assertEqual(parse_duration('0m0s'), 0) self.assertEqual(parse_duration('0s'), 0) self.assertEqual(parse_duration('01:02:03.05'), 3723.05) self.assertEqual(parse_duration('T30M38S'), 1838)