Skip to content

Commit d374c15

Browse files
committed
test(cudf): move infer_format regression tests to test_to_datetime.py
Address review feedback: relocate the parametrized infer_format unit test and the to_datetime integration regression test from test_astype.py to test_to_datetime.py, where datetime-related tests belong. No behavior change; the module-level infer_format import moves with them.
1 parent eda23b0 commit d374c15

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

python/cudf/cudf/tests/general_functions/test_to_datetime.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from cudf.testing._utils import (
1313
assert_exceptions_equal,
1414
)
15+
from cudf.utils.temporal import infer_format
1516

1617

1718
@pytest.mark.parametrize(
@@ -434,3 +435,21 @@ def test_datetime_index_tz_dtype_wall_time(data):
434435
)
435436
expected = pd.DatetimeIndex(data, dtype="datetime64[s, US/Eastern]")
436437
assert_eq(result, expected)
438+
439+
440+
@pytest.mark.parametrize(
441+
"bad_input",
442+
["1.2", "9.9", "2078~1.15"],
443+
)
444+
def test_infer_format_rejects_non_datetime_dotted_strings(bad_input):
445+
with pytest.raises(
446+
ValueError, match="Unable to infer the timestamp format"
447+
):
448+
infer_format(bad_input)
449+
450+
451+
def test_to_datetime_rejects_non_datetime_dotted_string():
452+
with pytest.raises(
453+
ValueError, match="Unable to infer the timestamp format"
454+
):
455+
cudf.to_datetime(cudf.Series(["1.2"]))

python/cudf/cudf/tests/series/methods/test_astype.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from cudf.core.column.numerical import NumericalColumn
1616
from cudf.testing import assert_eq
1717
from cudf.testing._utils import assert_exceptions_equal, expect_warning_if
18-
from cudf.utils.temporal import infer_format
1918

2019

2120
@pytest.mark.parametrize(
@@ -596,24 +595,6 @@ def test_str_to_datetime_error():
596595
)
597596

598597

599-
@pytest.mark.parametrize(
600-
"bad_input",
601-
["1.2", "9.9", "2078~1.15"],
602-
)
603-
def test_infer_format_rejects_non_datetime_dotted_strings(bad_input):
604-
with pytest.raises(
605-
ValueError, match="Unable to infer the timestamp format"
606-
):
607-
infer_format(bad_input)
608-
609-
610-
def test_to_datetime_rejects_non_datetime_dotted_string():
611-
with pytest.raises(
612-
ValueError, match="Unable to infer the timestamp format"
613-
):
614-
cudf.to_datetime(cudf.Series(["1.2"]))
615-
616-
617598
@pytest.mark.parametrize("timezone", ["", "Z"])
618599
@pytest.mark.parametrize(
619600
"data",

0 commit comments

Comments
 (0)