Skip to content

Commit 33e24a3

Browse files
author
MomIsBestFriend
committed
Refactored the test case to use 'box_with_array'
1 parent 2cf0756 commit 33e24a3

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

pandas/tests/arithmetic/test_datetime64.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Arithmetic tests for DataFrame/Series/Index/Array classes that should
22
# behave identically.
33
# Specifically for datetime64 and datetime64tz dtypes
4-
from datetime import datetime, timedelta
4+
from datetime import datetime, timedelta, time
55
from itertools import product, starmap
66
import operator
77
import warnings
@@ -1056,19 +1056,21 @@ def test_dt64arr_add_sub_parr(
10561056
)
10571057
assert_invalid_addsub_type(dtarr, parr, msg)
10581058

1059-
def test_timestamp_and_time_dtype_raises():
1060-
# https://github.com/pandas-dev/pandas/issues/10329
1061-
df = pd.DataFrame(
1062-
{
1063-
"date": pd.date_range("2012-01-01", periods=3),
1064-
"time": [time(i, i, i) for i in range(3)],
1065-
}
1066-
)
1059+
def test_timestamp_and_time_dtype_raises(self, box_with_array):
1060+
# https://github.com/pandas-dev/pandas/issues/10329
1061+
obj1 = pd.date_range("2012-01-01", periods=3)
1062+
obj2 = [time(i, i, i) for i in range(3)]
1063+
1064+
obj1 = tm.box_expected(obj1, box_with_array)
1065+
obj2 = tm.box_expected(obj2, box_with_array)
10671066

1068-
msg = r"unsupported operand type\(s\) for -: 'Timestamp' and 'datetime.time'"
1067+
msg = (
1068+
"unsupported operand type\(s\) for -: "
1069+
"'(Timestamp|DatetimeArray)' and 'datetime.time'"
1070+
)
10691071

1070-
with pytest.raises(TypeError, match=msg):
1071-
df["date"] - df["time"]
1072+
with pytest.raises(TypeError, match=msg):
1073+
obj1 - obj2
10721074

10731075

10741076
class TestDatetime64DateOffsetArithmetic:

0 commit comments

Comments
 (0)