Skip to content

Commit 55d78ca

Browse files
authored
TST: collect date_range tests, parametrize over unit (#55966)
* TST: collect date_range tests * misplaced date_range tests * parametrize over unit
1 parent e89d18c commit 55d78ca

File tree

5 files changed

+393
-279
lines changed

5 files changed

+393
-279
lines changed

pandas/tests/indexes/datetimes/test_constructors.py

+3-27
Original file line numberDiff line numberDiff line change
@@ -598,17 +598,10 @@ def test_integer_values_and_tz_interpreted_as_utc(self):
598598
# but UTC is *not* deprecated.
599599
with tm.assert_produces_warning(None):
600600
result = DatetimeIndex(values, tz="UTC")
601-
expected = DatetimeIndex(["2000-01-01T00:00:00"], tz="US/Central")
601+
expected = DatetimeIndex(["2000-01-01T00:00:00"], tz="UTC")
602+
tm.assert_index_equal(result, expected)
602603

603604
def test_constructor_coverage(self):
604-
rng = date_range("1/1/2000", periods=10.5)
605-
exp = date_range("1/1/2000", periods=10)
606-
tm.assert_index_equal(rng, exp)
607-
608-
msg = "periods must be a number, got foo"
609-
with pytest.raises(TypeError, match=msg):
610-
date_range(start="1/1/2000", periods="foo", freq="D")
611-
612605
msg = r"DatetimeIndex\(\.\.\.\) must be called with a collection"
613606
with pytest.raises(TypeError, match=msg):
614607
DatetimeIndex("1/1/2000")
@@ -647,17 +640,6 @@ def test_constructor_coverage(self):
647640
with pytest.raises(ValueError, match=msg):
648641
DatetimeIndex(["2000-01-01", "2000-01-02", "2000-01-04"], freq="D")
649642

650-
msg = (
651-
"Of the four parameters: start, end, periods, and freq, exactly "
652-
"three must be specified"
653-
)
654-
with pytest.raises(ValueError, match=msg):
655-
date_range(start="2011-01-01", freq="b")
656-
with pytest.raises(ValueError, match=msg):
657-
date_range(end="2011-01-01", freq="B")
658-
with pytest.raises(ValueError, match=msg):
659-
date_range(periods=10, freq="D")
660-
661643
@pytest.mark.parametrize("freq", ["YS", "W-SUN"])
662644
def test_constructor_datetime64_tzformat(self, freq):
663645
# see GH#6572: ISO 8601 format results in stdlib timezone object
@@ -762,10 +744,6 @@ def test_constructor_invalid_dtype_raises(self, dtype):
762744
with pytest.raises(ValueError, match=msg):
763745
DatetimeIndex([1, 2], dtype=dtype)
764746

765-
def test_constructor_name(self):
766-
idx = date_range(start="2000-01-01", periods=1, freq="YE", name="TEST")
767-
assert idx.name == "TEST"
768-
769747
def test_000constructor_resolution(self):
770748
# 2252
771749
t1 = Timestamp((1352934390 * 1000000000) + 1000000 + 1000 + 1)
@@ -921,9 +899,7 @@ def test_constructor_with_nonexistent_keyword_arg(self, warsaw):
921899
tm.assert_index_equal(result, expected)
922900

923901
# nonexistent keyword in end
924-
end = Timestamp("2015-03-29 02:30:00").tz_localize(
925-
timezone, nonexistent="shift_forward"
926-
)
902+
end = start
927903
result = date_range(end=end, periods=2, freq="h")
928904
expected = DatetimeIndex(
929905
[

0 commit comments

Comments
 (0)