Beispiel #1
0
def test_parse_time_string():
    time_string     = "12:53:56.123"
    result          = dateutil.parse( time_string )
    eq_( result.hour, 12)
    eq_( result.minute, 53)
    eq_( result.second, 56)
    assert_true( abs(result.microsecond-123000) <= 1 )
Beispiel #2
0
def test_raises_exception_on_bad_string_input():
    datetime_string = "bad string"

    try:
        result          = dateutil.parse( datetime_string )
        assert False, 'Expected an exception here'
    except dateutil.ParseException as e:
        eq_(str(e), "Unable to create datetime from 'bad string'")
Beispiel #3
0
def test_raises_exception_on_bad_datetime_input():
    datetime_string = "2012-12-6T00:12.2:00"

    try:
        result          = dateutil.parse( datetime_string )
        assert False, 'Expected an exception here'
    except dateutil.ParseException as e:
        eq_(str(e), "integer argument expected, got float")
Beispiel #4
0
def test_parse_time_string_without_fractional_seconds():
    time_string     = "12:53:56"
    result          = dateutil.parse( time_string )
    eq_( result.hour, 12)
    eq_( result.minute, 53)
    eq_( result.second, 56)
Beispiel #5
0
def test_parse_date_string():
    date_string     = "2012-12-06"
    result          = dateutil.parse( date_string )
    eq_( result, date( 2012, 12, 6 ) )
Beispiel #6
0
def test_parse_partial_datetime_string_with_no_delimiters():
    datetime_string = "20121206"
    result          = dateutil.parse( datetime_string )
    eq_( result, datetime( 2012, 12, 6 ) )
Beispiel #7
0
def test_parse_datetime_string_with_timezone_ending():
    datetime_string = "2012-12-06T12:53:56.123Z"
    result          = dateutil.parse( datetime_string )
    assert_true( abs(result-datetime( 2012, 12, 6, 12, 53, 56, 123000 )) < timedelta(microseconds=10) )
Beispiel #8
0
def test_parse_datetime_string_with_no_delimiters():
    datetime_string = "20121206125356"
    result          = dateutil.parse( datetime_string )
    eq_( result, datetime( 2012, 12, 6, 12, 53, 56 ) )
Beispiel #9
0
def test_parse_partial_datetime_string():
    datetime_string = "2012-12-06T12:53:56"
    result          = dateutil.parse( datetime_string )
    eq_( result, datetime( 2012, 12, 6, 12, 53, 56 ) )
Beispiel #10
0
def test_parse_full_datetime_string_with_space():
    datetime_string = "2012-12-06 12:53:56.123"
    result          = dateutil.parse( datetime_string )
    assert_true( abs(result-datetime( 2012, 12, 6, 12, 53, 56, 123000 )) < timedelta(microseconds=10) )
Beispiel #11
0
def test_parse_full_datetime_string_with_microseconds():
    datetime_string = "2013-06-21T20:30:40.066183Z"
    result          = dateutil.parse( datetime_string )
    eq_( result, datetime( 2013, 6, 21, 20, 30, 40, 66183 ) )