示例#1
0
def test_recursive_relative_pattern():
    path = os.path.join('foo', 'bar', '**', '*.txt')
    base_path, pattern, fullpath, recursive = uploader._extract_pathinfo(path)
    assert get_expected_path(os.path.join('foo', 'bar')) == base_path
    assert get_expected_path(path) == pattern
    assert not fullpath
    assert recursive
示例#2
0
def test_nonrecursive_absolute_pattern_multi_star(tmpdir):
    path = os.path.join(str(tmpdir), 'foo', 'bar', '*', '*.txt')
    base_path, pattern, fullpath, recursive = uploader._extract_pathinfo(path)
    assert os.path.join(str(tmpdir), 'foo', 'bar') == base_path
    assert path == pattern
    assert not fullpath
    assert not recursive
示例#3
0
def test_nonrecursive_relative_pattern_trailing_star():
    path = os.path.join('foo', 'bar', 'file*')
    base_path, pattern, fullpath, recursive = uploader._extract_pathinfo(path)
    assert get_expected_path(os.path.join('foo', 'bar')) == base_path
    assert get_expected_path(path) == pattern
    assert not fullpath
    assert not recursive
示例#4
0
def test_relative_path_with_dots():
    path = os.path.join('..', 'myfile.txt')
    expected_base_path = os.path.join(os.getcwd(), '..')
    expected_base_path = pathlib.Path(expected_base_path).resolve()
    base_path, pattern, fullpath, recursive = uploader._extract_pathinfo(path)
    assert str(expected_base_path) == base_path
    assert get_expected_path(path) == pattern
    assert fullpath
    assert not recursive
示例#5
0
def test_absolute_path_with_dots(tmpdir):
    folder = os.path.join(str(tmpdir), 'foo', 'bar', '..', '..')
    if not os.path.exists(folder):
        os.makedirs(folder)
    path = os.path.join(folder, 'myfile.txt')
    base_path, pattern, fullpath, recursive = uploader._extract_pathinfo(path)
    assert tmpdir == base_path
    assert path == pattern
    assert fullpath
    assert not recursive
示例#6
0
def test_path_with_environment_variable():
    os.environ['TEST'] = 'foo'
    if util.on_windows():
        env_var = '%TEST%'
    else:
        env_var = '$TEST'
    path = os.path.join(env_var, 'myfile.txt')
    base_path, pattern, fullpath, recursive = uploader._extract_pathinfo(path)
    assert get_expected_path('foo') == base_path
    assert get_expected_path(os.path.join('foo', 'myfile.txt')) == pattern
    assert fullpath
    assert not recursive