Skip to content

TST: collect date_range tests, parametrize over unit #55966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 3 additions & 27 deletions pandas/tests/indexes/datetimes/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,17 +598,10 @@ def test_integer_values_and_tz_interpreted_as_utc(self):
# but UTC is *not* deprecated.
with tm.assert_produces_warning(None):
result = DatetimeIndex(values, tz="UTC")
expected = DatetimeIndex(["2000-01-01T00:00:00"], tz="US/Central")
expected = DatetimeIndex(["2000-01-01T00:00:00"], tz="UTC")
tm.assert_index_equal(result, expected)

def test_constructor_coverage(self):
rng = date_range("1/1/2000", periods=10.5)
exp = date_range("1/1/2000", periods=10)
tm.assert_index_equal(rng, exp)

msg = "periods must be a number, got foo"
with pytest.raises(TypeError, match=msg):
date_range(start="1/1/2000", periods="foo", freq="D")

msg = r"DatetimeIndex\(\.\.\.\) must be called with a collection"
with pytest.raises(TypeError, match=msg):
DatetimeIndex("1/1/2000")
Expand Down Expand Up @@ -647,17 +640,6 @@ def test_constructor_coverage(self):
with pytest.raises(ValueError, match=msg):
DatetimeIndex(["2000-01-01", "2000-01-02", "2000-01-04"], freq="D")

msg = (
"Of the four parameters: start, end, periods, and freq, exactly "
"three must be specified"
)
with pytest.raises(ValueError, match=msg):
date_range(start="2011-01-01", freq="b")
with pytest.raises(ValueError, match=msg):
date_range(end="2011-01-01", freq="B")
with pytest.raises(ValueError, match=msg):
date_range(periods=10, freq="D")

@pytest.mark.parametrize("freq", ["YS", "W-SUN"])
def test_constructor_datetime64_tzformat(self, freq):
# see GH#6572: ISO 8601 format results in stdlib timezone object
Expand Down Expand Up @@ -762,10 +744,6 @@ def test_constructor_invalid_dtype_raises(self, dtype):
with pytest.raises(ValueError, match=msg):
DatetimeIndex([1, 2], dtype=dtype)

def test_constructor_name(self):
idx = date_range(start="2000-01-01", periods=1, freq="YE", name="TEST")
assert idx.name == "TEST"

def test_000constructor_resolution(self):
# 2252
t1 = Timestamp((1352934390 * 1000000000) + 1000000 + 1000 + 1)
Expand Down Expand Up @@ -921,9 +899,7 @@ def test_constructor_with_nonexistent_keyword_arg(self, warsaw):
tm.assert_index_equal(result, expected)

# nonexistent keyword in end
end = Timestamp("2015-03-29 02:30:00").tz_localize(
timezone, nonexistent="shift_forward"
)
end = start
result = date_range(end=end, periods=2, freq="h")
expected = DatetimeIndex(
[
Expand Down
Loading