()
| 134 | |
| 135 | |
| 136 | def test_stringify_path(): |
| 137 | test_filepath = os.path.join("path", "to", "file.txt") |
| 138 | |
| 139 | # Pathlib.path |
| 140 | path = pathlib.Path(test_filepath) |
| 141 | assert stringify_path(path) == test_filepath |
| 142 | |
| 143 | # fspath protocol |
| 144 | class CustomFSPath: |
| 145 | """For testing fspath on unknown objects""" |
| 146 | |
| 147 | def __init__(self, path): |
| 148 | self.path = path |
| 149 | |
| 150 | def __fspath__(self): |
| 151 | return self.path |
| 152 | |
| 153 | path = CustomFSPath(test_filepath) |
| 154 | assert stringify_path(path) == test_filepath |
| 155 | |
| 156 | # Non path-like input is unaffected |
| 157 | path = (1, 2, 3) |
| 158 | assert stringify_path(path) is path |
nothing calls this directly
no test coverage detected