Made everything absolute on the pathresolver.py, didn't help
This commit is contained in:
parent
6c32b9720c
commit
b056db9c8d
|
|
@ -1,5 +1,6 @@
|
|||
# Module for resolving relative path problems
|
||||
|
||||
# import pathlib
|
||||
import os
|
||||
|
||||
|
||||
|
|
@ -10,7 +11,7 @@ class PathResolver:
|
|||
"""
|
||||
|
||||
def __init__(self, base_path):
|
||||
self.base_path = os.path.normpath(os.path.dirname(base_path))
|
||||
self.base_path = os.path.normpath(os.path.join(os.getcwd(), os.path.dirname(base_path)))
|
||||
|
||||
def __call__(self, relative_path='.'):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,20 +1,12 @@
|
|||
import pathlib
|
||||
|
||||
import bootstraparse.modules.pathresolver as path_r
|
||||
import os
|
||||
import re
|
||||
import pytest
|
||||
|
||||
path_like_regexp = r'^([A-z]\:\\|/).+[/\\]src[/\\]bootstraparse[/\\]?$'
|
||||
test_path = '/a/b/c/test'
|
||||
test_path_win = test_path.replace('/', '\\')
|
||||
|
||||
|
||||
def test_PathResolver():
|
||||
path = path_r.PathResolver(test_path+"/")
|
||||
assert path() == os.path.normpath(test_path)
|
||||
assert path().replace('/', '\\') == test_path_win
|
||||
assert path().replace('\\', '/') == test_path
|
||||
# test_path = '/a/b/c/test'
|
||||
# test_path_win = test_path.replace('/', '\\')
|
||||
|
||||
|
||||
def test_BoostraPath():
|
||||
|
|
@ -33,6 +25,8 @@ def test_b_path():
|
|||
('/a/b/c/test.py', './', '/a/b/c/'),
|
||||
('/a/b/c/test.py', './test2.py', '/a/b/c/test2.py'),
|
||||
('/a/b/c/test.py', '../test2.py', '/a/b/test2.py'),
|
||||
('/a/b/c/test.py', '/d/test2.py', '/d/test2.py'),
|
||||
('/a/b/c/test.py', '../d/test2.py', '/a/b/d/test2.py'),
|
||||
])
|
||||
def test_path_call(init, path, result):
|
||||
assert pathlib.Path(path_r.PathResolver(init)(path)) == pathlib.Path(result)
|
||||
assert pathlib.Path(path_r.PathResolver(init)(path)).parts[1:] == pathlib.Path(result).parts[1:]
|
||||
|
|
|
|||
Loading…
Reference in New Issue