Skip to content

Commit

Permalink
Move tests that dont belong in test_offsets (#18747)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and jreback committed Dec 13, 2017
1 parent 9705a48 commit 040470a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
40 changes: 40 additions & 0 deletions pandas/tests/scalar/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,51 @@
import pytest
from dateutil.parser import parse

import pandas as pd
import pandas.util._test_decorators as td
from pandas.conftest import is_dateutil_le_261, is_dateutil_gt_261
from pandas import compat
from pandas.util import testing as tm
from pandas._libs.tslibs import parsing
from pandas._libs.tslibs.parsing import parse_time_string


def test_to_datetime1():
actual = pd.to_datetime(datetime(2008, 1, 15))
assert actual == datetime(2008, 1, 15)

actual = pd.to_datetime('20080115')
assert actual == datetime(2008, 1, 15)

# unparseable
s = 'Month 1, 1999'
assert pd.to_datetime(s, errors='ignore') == s


class TestParseQuarters(object):

def test_parse_time_string(self):
(date, parsed, reso) = parse_time_string('4Q1984')
(date_lower, parsed_lower, reso_lower) = parse_time_string('4q1984')
assert date == date_lower
assert parsed == parsed_lower
assert reso == reso_lower

def test_parse_time_quarter_w_dash(self):
# https://github.com/pandas-dev/pandas/issue/9688
pairs = [('1988-Q2', '1988Q2'), ('2Q-1988', '2Q1988')]

for dashed, normal in pairs:
(date_dash, parsed_dash, reso_dash) = parse_time_string(dashed)
(date, parsed, reso) = parse_time_string(normal)

assert date_dash == date
assert parsed_dash == parsed
assert reso_dash == reso

pytest.raises(parsing.DateParseError, parse_time_string, "-2Q1992")
pytest.raises(parsing.DateParseError, parse_time_string, "2-Q1992")
pytest.raises(parsing.DateParseError, parse_time_string, "4-4Q1992")


class TestDatetimeParsingWrappers(object):
Expand Down
42 changes: 1 addition & 41 deletions pandas/tests/tseries/offsets/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
QuarterEnd, BusinessMonthEnd, FY5253,
Nano, Easter, FY5253Quarter,
LastWeekOfMonth)
from pandas.core.tools.datetimes import (
format, ole2datetime, parse_time_string,
to_datetime, DateParseError)
from pandas.core.tools.datetimes import format, ole2datetime
import pandas.tseries.offsets as offsets
from pandas.io.pickle import read_pickle
from pandas._libs.tslibs import timezones
Expand Down Expand Up @@ -67,18 +65,6 @@ def test_ole2datetime():
ole2datetime(60)


def test_to_datetime1():
actual = to_datetime(datetime(2008, 1, 15))
assert actual == datetime(2008, 1, 15)

actual = to_datetime('20080115')
assert actual == datetime(2008, 1, 15)

# unparseable
s = 'Month 1, 1999'
assert to_datetime(s, errors='ignore') == s


def test_normalize_date():
actual = normalize_date(datetime(2007, 10, 1, 1, 12, 5, 10))
assert actual == datetime(2007, 10, 1)
Expand Down Expand Up @@ -2800,32 +2786,6 @@ def test_get_offset_legacy():
get_offset(name)


class TestParseTimeString(object):

def test_parse_time_string(self):
(date, parsed, reso) = parse_time_string('4Q1984')
(date_lower, parsed_lower, reso_lower) = parse_time_string('4q1984')
assert date == date_lower
assert parsed == parsed_lower
assert reso == reso_lower

def test_parse_time_quarter_w_dash(self):
# https://github.com/pandas-dev/pandas/issue/9688
pairs = [('1988-Q2', '1988Q2'), ('2Q-1988', '2Q1988'), ]

for dashed, normal in pairs:
(date_dash, parsed_dash, reso_dash) = parse_time_string(dashed)
(date, parsed, reso) = parse_time_string(normal)

assert date_dash == date
assert parsed_dash == parsed
assert reso_dash == reso

pytest.raises(DateParseError, parse_time_string, "-2Q1992")
pytest.raises(DateParseError, parse_time_string, "2-Q1992")
pytest.raises(DateParseError, parse_time_string, "4-4Q1992")


def test_get_standard_freq():
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
fstr = get_standard_freq('W')
Expand Down

0 comments on commit 040470a

Please sign in to comment.