コード例 #1
0
def test_abspath_get_parent_on_unix():
    src_path = os.path.join('/', 'd', 'e')
    path = Path(src_path)
    assert path.get_parent(1) == path.dirname
    assert path.get_parent(1) == os.path.join('/', 'd')
    assert path.get_parent(2) == '/'
    assert path.get_parent(3) is None
    assert path.get_parent(4) is None
コード例 #2
0
def test_relpath_get_parent_when_root_is_curdir():
    src_path = os.path.join(os.path.curdir, 'a', 'b', 'c')
    path = Path(src_path)
    assert path.get_parent(1) == path.dirname
    assert path.get_parent(1) == os.path.join(os.path.curdir, 'a', 'b')
    assert path.get_parent(2) == os.path.join(os.path.curdir, 'a')
    assert path.get_parent(3) == os.path.curdir
    for i in range(1, 10):
        assert path.get_parent(3+i) == os.path.join(*([os.path.pardir] * i))
コード例 #3
0
def test_relpath_get_parent_when_path_is_pardir():
    src_path = os.path.pardir
    path = Path(src_path)
    assert path.get_parent(1) == path.dirname
    for i in range(1, 10):
        assert path.get_parent(i) == os.path.join(*([os.path.pardir] * (1+i)))