Example #1
0
def test_path_div():
    ' allow to use `Path() / str()` expr '

    path = Path.from_argv()
    new_path = path / 'abc'
    assert isinstance(path, Path)
    assert new_path == os.path.join(sys.argv[0], 'abc')
Example #2
0
def test_is_abspath():
    abspath = Path.from_argv()
    assert abspath.is_abspath()
    assert abspath == sys.argv[0]

    relpath = Path('abc')  # rel path
    assert relpath.get_abspath().is_abspath()
    assert relpath.get_abspath() == os.path.abspath('abc')
def test_path_from_argv():
    path = Path.from_argv()
    assert path == sys.argv[0]
Example #4
0
def test_abspath_join():
    # join with pardir
    path = Path.from_argv() / os.path.pardir
    assert path.is_abspath()
    assert path == os.path.dirname(sys.argv[0])
Example #5
0
def test_abspath_get_parent():
    path = Path.from_argv(0)
    parent = path.get_parent()
    assert parent == os.path.dirname(sys.argv[0])
Example #6
0
def test_get_abspath():
    abspath = Path.from_argv()
    assert abspath is abspath.get_abspath()
Example #7
0
def test_path_equals():
    path = Path.from_argv()
    path_str = sys.argv[0]
    assert type(path) != type(path_str)
    assert path == path_str
    assert path_str == path
Example #8
0
def test_path_types():
    path = Path.from_argv()
    assert isinstance(path, Path)
    assert isinstance(path, str)
    assert issubclass(Path, str)