A 'safe' alternative to os.path.relpath(). Avoids an exception on Windows if the drive needs to change - in this case we use os.path.abspath().
(path, start=None)
| 1349 | |
| 1350 | |
| 1351 | def relpath(path, start=None): |
| 1352 | ''' |
| 1353 | A 'safe' alternative to os.path.relpath(). Avoids an exception on Windows |
| 1354 | if the drive needs to change - in this case we use os.path.abspath(). |
| 1355 | ''' |
| 1356 | try: |
| 1357 | return os.path.relpath(path, start) |
| 1358 | except ValueError: |
| 1359 | # os.path.relpath() fails if trying to change drives. |
| 1360 | assert platform.system() == 'Windows' |
| 1361 | return os.path.abspath(path) |
| 1362 | |
| 1363 | |
| 1364 | def test_open(): |
no outgoing calls
no test coverage detected
searching dependent graphs…