|
5 | 5 | import pandas as pd
|
6 | 6 | from typing_extensions import assert_type
|
7 | 7 |
|
8 |
| -from tests import check |
| 8 | +from tests import ( |
| 9 | + PD_LTE_23, |
| 10 | + check, |
| 11 | +) |
9 | 12 |
|
10 | 13 | left = pd.DataFrame({"a": [1, 2, 3]})["a"] # left operand
|
11 | 14 |
|
@@ -140,12 +143,24 @@ def test_truediv_pd_series() -> None:
|
140 | 143 | check(assert_type(left.rdiv(c), pd.Series), pd.Series)
|
141 | 144 |
|
142 | 145 |
|
| 146 | +def test_path_div() -> None: |
| 147 | + # GH 682 |
| 148 | + folder = Path.cwd() |
| 149 | + |
| 150 | + folders = pd.Series([folder, folder]) |
| 151 | + check(assert_type(folders / Path("a.png"), pd.Series), pd.Series, Path) |
| 152 | + |
| 153 | + |
143 | 154 | def test_truediv_path() -> None:
|
144 |
| - """Test pd.Series / path object""" |
145 |
| - left, p = pd.Series(["pat", "ath", "path"]), Path() |
| 155 | + """Test pd.Series / path object. |
| 156 | +
|
| 157 | + Also GH 682.""" |
| 158 | + left, p = pd.Series(["a.png", "b.gz", "c.txt"]), Path.cwd() |
146 | 159 |
|
147 | 160 | check(assert_type(left / p, pd.Series), pd.Series, Path)
|
148 |
| - check(assert_type(p / left, pd.Series), pd.Series, Path) |
| 161 | + if PD_LTE_23: |
| 162 | + # Bug in 3.0 https://github.com/pandas-dev/pandas/issues/61940 |
| 163 | + check(assert_type(p / left, pd.Series), pd.Series, Path) |
149 | 164 |
|
150 | 165 | check(assert_type(left.truediv(p), pd.Series), pd.Series, Path)
|
151 | 166 | check(assert_type(left.div(p), pd.Series), pd.Series, Path)
|
|
0 commit comments