|
17 | 17 |
|
18 | 18 | import os |
19 | 19 | import pickle |
| 20 | +import sys |
20 | 21 | import tempfile |
21 | 22 | from typing import Any |
22 | 23 |
|
|
27 | 28 | PY_IO_IMPL, |
28 | 29 | _import_file_io, |
29 | 30 | _infer_file_io_from_scheme, |
| 31 | + _is_windows_drive_letter, |
30 | 32 | load_file_io, |
31 | 33 | ) |
32 | 34 | from pyiceberg.io.pyarrow import PyArrowFileIO |
@@ -339,3 +341,31 @@ def test_infer_file_io_from_schema_unknown() -> None: |
339 | 341 | _infer_file_io_from_scheme("unknown://bucket/path/", {}) |
340 | 342 |
|
341 | 343 | assert str(w[0].message) == "No preferred file implementation for scheme: unknown" |
| 344 | + |
| 345 | + |
| 346 | +@pytest.mark.parametrize( |
| 347 | + "scheme", |
| 348 | + ["s3", "hdfs", "file", "gs", ""], |
| 349 | +) |
| 350 | +def test_is_windows_drive_letter_false_for_real_schemes(scheme: str) -> None: |
| 351 | + assert _is_windows_drive_letter(scheme) is False |
| 352 | + |
| 353 | + |
| 354 | +@pytest.mark.skipif(sys.platform != "win32", reason="Windows-only behavior") |
| 355 | +@pytest.mark.parametrize("scheme", ["c", "D", "z"]) |
| 356 | +def test_is_windows_drive_letter_true_on_windows(scheme: str) -> None: |
| 357 | + assert _is_windows_drive_letter(scheme) is True |
| 358 | + |
| 359 | + |
| 360 | +@pytest.mark.skipif(sys.platform != "win32", reason="Windows-only behavior") |
| 361 | +def test_infer_file_io_from_scheme_windows_drive_letter() -> None: |
| 362 | + # A Windows-style path like 'C:\Users\...' should be treated as a local file path, |
| 363 | + # not as a URL with scheme 'c' |
| 364 | + result = _infer_file_io_from_scheme(r"C:\Users\test\warehouse", {}) |
| 365 | + assert isinstance(result, PyArrowFileIO) |
| 366 | + |
| 367 | + |
| 368 | +@pytest.mark.skipif(sys.platform != "win32", reason="Windows-only behavior") |
| 369 | +def test_infer_file_io_from_scheme_windows_drive_letter_lowercase() -> None: |
| 370 | + result = _infer_file_io_from_scheme(r"d:\data\iceberg\table", {}) |
| 371 | + assert isinstance(result, PyArrowFileIO) |
0 commit comments