|
1 | 1 | import sys |
2 | 2 | import pathlib |
3 | 3 | import warnings |
| 4 | +from pathlib import Path |
4 | 5 |
|
5 | 6 | import pytest |
6 | 7 |
|
@@ -52,3 +53,34 @@ def test_multiple_backend_paths(local_testdir, s3, hdfs): |
52 | 53 | path = f"hdfs:{local_testdir}" |
53 | 54 | UPath(path, host=host, user=user, port=port) |
54 | 55 | assert s3_path.joinpath("text1.txt")._url.scheme == "s3" |
| 56 | + |
| 57 | + |
| 58 | +def test_constructor_accept_path(local_testdir): |
| 59 | + path = UPath(pathlib.Path(local_testdir)) |
| 60 | + assert str(path) == str(Path(local_testdir)) |
| 61 | + |
| 62 | + |
| 63 | +def test_constructor_accept_upath(local_testdir): |
| 64 | + path = UPath(UPath(local_testdir)) |
| 65 | + assert str(path) == str(Path(local_testdir)) |
| 66 | + |
| 67 | + |
| 68 | +def test_subclass(local_testdir): |
| 69 | + class MyPath(UPath): |
| 70 | + pass |
| 71 | + |
| 72 | + path = MyPath(local_testdir) |
| 73 | + assert str(path) == str(Path(local_testdir)) |
| 74 | + assert issubclass(MyPath, UPath) |
| 75 | + assert isinstance(path, pathlib.Path) |
| 76 | + |
| 77 | + |
| 78 | +def test_instance_check(local_testdir): |
| 79 | + path = UPath(local_testdir) |
| 80 | + assert isinstance(path, UPath) |
| 81 | + |
| 82 | + |
| 83 | +def test_new_method(local_testdir): |
| 84 | + path = UPath.__new__(pathlib.Path, local_testdir) |
| 85 | + assert str(path) == str(Path(local_testdir)) |
| 86 | + assert isinstance(path, pathlib.Path) |
0 commit comments