Skip to content

Commit b4c825d

Browse files
author
Robert Schmidtke
committed
expand test for demonstration purposes
1 parent d0675f4 commit b4c825d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

pandas/tests/tslibs/test_array_to_datetime.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,21 @@ def test_to_datetime_barely_out_of_bounds():
272272
tslib.array_to_datetime(arr)
273273

274274

275-
def test_to_datetime_barely_inside_bounds():
275+
@pytest.mark.parametrize(
276+
"timestamp",
277+
[
278+
# Close enough to bounds that scaling micros to nanos overflows
279+
# but adding nanos would result in an in-bounds datetime.
280+
"1677-09-21T00:12:43.145224193",
281+
"1677-09-21T00:12:43.145224999",
282+
# this always worked
283+
"1677-09-21T00:12:43.145225000",
284+
],
285+
)
286+
def test_to_datetime_barely_inside_bounds(timestamp):
276287
# see gh-57150
277-
#
278-
# Close enough to bounds that scaling micros to nanos overflows
279-
# but adding nanos would result in an in-bounds datetime.
280-
arr = np.array(["1677-09-21T00:12:43.145224193"], dtype=object)
281-
result, _ = tslib.array_to_datetime(arr)
282-
expected = ["1677-09-21T00:12:43.145224193"]
283-
tm.assert_numpy_array_equal(result, np.array(expected, dtype="M8[ns]"))
288+
result, _ = tslib.array_to_datetime(np.array([timestamp], dtype=object))
289+
tm.assert_numpy_array_equal(result, np.array([timestamp], dtype="M8[ns]"))
284290

285291

286292
class SubDatetime(datetime):

0 commit comments

Comments
 (0)