|
7 | 7 |
|
8 | 8 | from tests import (
|
9 | 9 | PD_LTE_23,
|
| 10 | + WINDOWS, |
10 | 11 | check,
|
11 | 12 | )
|
12 | 13 |
|
@@ -143,27 +144,37 @@ def test_truediv_pd_series() -> None:
|
143 | 144 | check(assert_type(left.rdiv(c), pd.Series), pd.Series)
|
144 | 145 |
|
145 | 146 |
|
146 |
| -def test_path_div() -> None: |
147 |
| - # GH 682 |
148 |
| - folder = Path.cwd() |
| 147 | +def test_path_div(tmp_path: Path) -> None: |
| 148 | + """Test pd.Series of paths / path object. |
149 | 149 |
|
150 |
| - folders = pd.Series([folder, folder]) |
151 |
| - check(assert_type(folders / Path("a.png"), pd.Series), pd.Series, Path) |
| 150 | + Also GH 682.""" |
| 151 | + fpath = Path("a.png") |
| 152 | + folders, fpaths = pd.Series([tmp_path, tmp_path]), pd.Series([fpath, fpath]) |
| 153 | + |
| 154 | + check(assert_type(folders / fpath, pd.Series), pd.Series, Path) |
| 155 | + check(assert_type(folders.truediv(fpath), pd.Series), pd.Series, Path) |
| 156 | + check(assert_type(folders.div(fpath), pd.Series), pd.Series, Path) |
| 157 | + |
| 158 | + check(assert_type(tmp_path / fpaths, pd.Series), pd.Series, Path) |
| 159 | + check(assert_type(fpaths.rtruediv(tmp_path), pd.Series), pd.Series, Path) |
| 160 | + check(assert_type(fpaths.rdiv(tmp_path), pd.Series), pd.Series, Path) |
152 | 161 |
|
153 | 162 |
|
154 |
| -def test_truediv_path() -> None: |
| 163 | +def test_truediv_path(tmp_path: Path) -> None: |
155 | 164 | """Test pd.Series / path object.
|
156 | 165 |
|
157 | 166 | Also GH 682."""
|
158 |
| - left, p = pd.Series(["a.png", "b.gz", "c.txt"]), Path.cwd() |
| 167 | + fnames = pd.Series(["a.png", "b.gz", "c.txt"]) |
159 | 168 |
|
160 |
| - check(assert_type(left / p, pd.Series), pd.Series, Path) |
161 | 169 | if PD_LTE_23:
|
162 | 170 | # Bug in 3.0 https://github.com/pandas-dev/pandas/issues/61940
|
163 |
| - check(assert_type(p / left, pd.Series), pd.Series, Path) |
| 171 | + check(assert_type(fnames / tmp_path, pd.Series), pd.Series, Path) |
| 172 | + check(assert_type(tmp_path / fnames, pd.Series), pd.Series, Path) |
164 | 173 |
|
165 |
| - check(assert_type(left.truediv(p), pd.Series), pd.Series, Path) |
166 |
| - check(assert_type(left.div(p), pd.Series), pd.Series, Path) |
| 174 | + if PD_LTE_23 or not WINDOWS: |
| 175 | + # pyarrow.lib.ArrowInvalid: Could not convert WindowsPath('...') with type WindowsPath: did not recognize Python value type when inferring an Arrow data type |
| 176 | + check(assert_type(fnames.truediv(tmp_path), pd.Series), pd.Series, Path) |
| 177 | + check(assert_type(fnames.div(tmp_path), pd.Series), pd.Series, Path) |
167 | 178 |
|
168 |
| - check(assert_type(left.rtruediv(p), pd.Series), pd.Series, Path) |
169 |
| - check(assert_type(left.rdiv(p), pd.Series), pd.Series, Path) |
| 179 | + check(assert_type(fnames.rtruediv(tmp_path), pd.Series), pd.Series, Path) |
| 180 | + check(assert_type(fnames.rdiv(tmp_path), pd.Series), pd.Series, Path) |
0 commit comments