mirror of https://github.com/flaggo/pydu.git
add path.normjoin
This commit is contained in:
parent
7492f3280f
commit
25df88abe9
|
@ -34,3 +34,8 @@ def is_super_path(path1, path2):
|
||||||
parent_path2 = os.path.dirname(parent_path2)
|
parent_path2 = os.path.dirname(parent_path2)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def normjoin(path, *paths):
|
||||||
|
"""Join one or more path components intelligently and normalize it."""
|
||||||
|
return os.path.normpath(os.path.join(path, *paths))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
from pydu.platform import WINDOWS
|
from pydu.platform import WINDOWS
|
||||||
from pydu.path import cd, is_super_path
|
from pydu.path import cd, is_super_path, normjoin
|
||||||
|
|
||||||
|
|
||||||
def test_cd(tmpdir):
|
def test_cd(tmpdir):
|
||||||
|
@ -27,3 +27,9 @@ class TestIsSupoerPath:
|
||||||
assert is_super_path('c:/aa/bb', 'c:/aa\\bb/cc')
|
assert is_super_path('c:/aa/bb', 'c:/aa\\bb/cc')
|
||||||
assert is_super_path('c:/aa\\bb', 'c:\\aa/bb/cc')
|
assert is_super_path('c:/aa\\bb', 'c:\\aa/bb/cc')
|
||||||
assert is_super_path('c:/', 'c:\\')
|
assert is_super_path('c:/', 'c:\\')
|
||||||
|
|
||||||
|
|
||||||
|
def test_normjoin():
|
||||||
|
assert normjoin('/a', 'b') == '/a/b'
|
||||||
|
assert normjoin('/a', '/b') == '/b'
|
||||||
|
assert normjoin('/a', '../b') == '/b'
|
||||||
|
|
Loading…
Reference in New Issue