Python pandas._libs.tslib._test_parse_iso8601() Examples

The following are 14 code examples of pandas._libs.tslib._test_parse_iso8601(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pandas._libs.tslib , or try the search function .
Example #1
Source File: test_parse_iso8601.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_parsers_iso8601(date_str, exp):
    # see gh-12060
    #
    # Test only the ISO parser - flexibility to
    # different separators and leading zero's.
    actual = tslib._test_parse_iso8601(date_str)
    assert actual == exp 
Example #2
Source File: test_parse_iso8601.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_parsers_iso8601_invalid(date_str):
    msg = "Error parsing datetime string \"{s}\"".format(s=date_str)

    with pytest.raises(ValueError, match=msg):
        tslib._test_parse_iso8601(date_str) 
Example #3
Source File: test_parse_iso8601.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_parsers_iso8601_invalid_offset_invalid():
    date_str = "2001-01-01 12-34-56"
    msg = ("Timezone hours offset out of range "
           "in datetime string \"{s}\"".format(s=date_str))

    with pytest.raises(ValueError, match=msg):
        tslib._test_parse_iso8601(date_str) 
Example #4
Source File: test_array_to_datetime.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_parsers_iso8601(self, date_str, exp):
        # GH#12060
        # test only the iso parser - flexibility to different
        # separators and leadings 0s
        # Timestamp construction falls back to dateutil
        actual = tslib._test_parse_iso8601(date_str)
        assert actual == exp 
Example #5
Source File: test_array_to_datetime.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_parsers_iso8601_invalid(self, date_str):
        # separators must all match - YYYYMM not valid
        with pytest.raises(ValueError):
            tslib._test_parse_iso8601(date_str) 
Example #6
Source File: test_parse_iso8601.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_parsers_iso8601(date_str, exp):
    # see gh-12060
    #
    # Test only the ISO parser - flexibility to
    # different separators and leading zero's.
    actual = tslib._test_parse_iso8601(date_str)
    assert actual == exp 
Example #7
Source File: test_parse_iso8601.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_parsers_iso8601_invalid(date_str):
    msg = "Error parsing datetime string \"{s}\"".format(s=date_str)

    with pytest.raises(ValueError, match=msg):
        tslib._test_parse_iso8601(date_str) 
Example #8
Source File: test_parse_iso8601.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_parsers_iso8601_invalid_offset_invalid():
    date_str = "2001-01-01 12-34-56"
    msg = ("Timezone hours offset out of range "
           "in datetime string \"{s}\"".format(s=date_str))

    with pytest.raises(ValueError, match=msg):
        tslib._test_parse_iso8601(date_str) 
Example #9
Source File: test_tools.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_parsers_iso8601(self):
        # GH 12060
        # test only the iso parser - flexibility to different
        # separators and leadings 0s
        # Timestamp construction falls back to dateutil
        cases = {'2011-01-02': datetime(2011, 1, 2),
                 '2011-1-2': datetime(2011, 1, 2),
                 '2011-01': datetime(2011, 1, 1),
                 '2011-1': datetime(2011, 1, 1),
                 '2011 01 02': datetime(2011, 1, 2),
                 '2011.01.02': datetime(2011, 1, 2),
                 '2011/01/02': datetime(2011, 1, 2),
                 '2011\\01\\02': datetime(2011, 1, 2),
                 '2013-01-01 05:30:00': datetime(2013, 1, 1, 5, 30),
                 '2013-1-1 5:30:00': datetime(2013, 1, 1, 5, 30)}
        for date_str, exp in compat.iteritems(cases):
            actual = tslib._test_parse_iso8601(date_str)
            assert actual == exp

        # seperators must all match - YYYYMM not valid
        invalid_cases = ['2011-01/02', '2011^11^11',
                         '201401', '201111', '200101',
                         # mixed separated and unseparated
                         '2005-0101', '200501-01',
                         '20010101 12:3456', '20010101 1234:56',
                         # HHMMSS must have two digits in each component
                         # if unseparated
                         '20010101 1', '20010101 123', '20010101 12345',
                         '20010101 12345Z',
                         # wrong separator for HHMMSS
                         '2001-01-01 12-34-56']
        for date_str in invalid_cases:
            with pytest.raises(ValueError):
                tslib._test_parse_iso8601(date_str)
                # If no ValueError raised, let me know which case failed.
                raise Exception(date_str) 
Example #10
Source File: test_parse_iso8601.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_parsers_iso8601(date_str, exp):
    # see gh-12060
    #
    # Test only the ISO parser - flexibility to
    # different separators and leading zero's.
    actual = tslib._test_parse_iso8601(date_str)
    assert actual == exp 
Example #11
Source File: test_parse_iso8601.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_parsers_iso8601_invalid(date_str):
    msg = "Error parsing datetime string \"{s}\"".format(s=date_str)

    with pytest.raises(ValueError, match=msg):
        tslib._test_parse_iso8601(date_str) 
Example #12
Source File: test_parse_iso8601.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_parsers_iso8601_invalid_offset_invalid():
    date_str = "2001-01-01 12-34-56"
    msg = ("Timezone hours offset out of range "
           "in datetime string \"{s}\"".format(s=date_str))

    with pytest.raises(ValueError, match=msg):
        tslib._test_parse_iso8601(date_str) 
Example #13
Source File: test_array_to_datetime.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_parsers_iso8601(self, date_str, exp):
        # GH#12060
        # test only the iso parser - flexibility to different
        # separators and leadings 0s
        # Timestamp construction falls back to dateutil
        actual = tslib._test_parse_iso8601(date_str)
        assert actual == exp 
Example #14
Source File: test_array_to_datetime.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_parsers_iso8601_invalid(self, date_str):
        # separators must all match - YYYYMM not valid
        with pytest.raises(ValueError):
            tslib._test_parse_iso8601(date_str)