|
11 | 11 | import pytest
|
12 | 12 |
|
13 | 13 | from pandas._libs import lib
|
| 14 | +from pandas._libs.missing import NA |
14 | 15 | from pandas._libs.tslibs import (
|
15 | 16 | NaT,
|
16 | 17 | iNaT,
|
@@ -138,6 +139,19 @@ def test_truediv_numeric(self, td):
|
138 | 139 | assert res._value == td._value / 2
|
139 | 140 | assert res._creso == td._creso
|
140 | 141 |
|
| 142 | + def test_truediv_na_type_not_supported(self, td): |
| 143 | + msg_td_floordiv_na = ( |
| 144 | + r"unsupported operand type\(s\) for /: 'Timedelta' and 'NAType'" |
| 145 | + ) |
| 146 | + with pytest.raises(TypeError, match=msg_td_floordiv_na): |
| 147 | + td / NA |
| 148 | + |
| 149 | + msg_na_floordiv_td = ( |
| 150 | + r"unsupported operand type\(s\) for /: 'NAType' and 'Timedelta'" |
| 151 | + ) |
| 152 | + with pytest.raises(TypeError, match=msg_na_floordiv_td): |
| 153 | + NA / td |
| 154 | + |
141 | 155 | def test_floordiv_timedeltalike(self, td):
|
142 | 156 | assert td // td == 1
|
143 | 157 | assert (2.5 * td) // td == 2
|
@@ -182,6 +196,19 @@ def test_floordiv_numeric(self, td):
|
182 | 196 | assert res._value == td._value // 2
|
183 | 197 | assert res._creso == td._creso
|
184 | 198 |
|
| 199 | + def test_floordiv_na_type_not_supported(self, td): |
| 200 | + msg_td_floordiv_na = ( |
| 201 | + r"unsupported operand type\(s\) for //: 'Timedelta' and 'NAType'" |
| 202 | + ) |
| 203 | + with pytest.raises(TypeError, match=msg_td_floordiv_na): |
| 204 | + td // NA |
| 205 | + |
| 206 | + msg_na_floordiv_td = ( |
| 207 | + r"unsupported operand type\(s\) for //: 'NAType' and 'Timedelta'" |
| 208 | + ) |
| 209 | + with pytest.raises(TypeError, match=msg_na_floordiv_td): |
| 210 | + NA // td |
| 211 | + |
185 | 212 | def test_addsub_mismatched_reso(self, td):
|
186 | 213 | # need to cast to since td is out of bounds for ns, so
|
187 | 214 | # so we would raise OverflowError without casting
|
|
0 commit comments