def test_parse_timestamp_invalid(): with pytest.raises(ValueError): parse_timestamp('zz')
def test_parse_timestamp_fractional(): timestamp = parse_timestamp('2013-08-24T03:17:56.242421Z') assert timestamp == datetime(2013, 8, 24, 3, 17, 56, 242421)
def test_parse_timestamp_timestamp(): dt = datetime(2013, 8, 24, 3, 17, 56, 242421) timestamp = parse_timestamp(dt) assert timestamp == dt
def test_parse_timestamp(): timestamp = parse_timestamp('2013-08-24T23:17:56Z') assert timestamp == datetime(2013, 8, 24, 23, 17, 56)