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')
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]
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])
def test_abspath_get_parent(): path = Path.from_argv(0) parent = path.get_parent() assert parent == os.path.dirname(sys.argv[0])
def test_get_abspath(): abspath = Path.from_argv() assert abspath is abspath.get_abspath()
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
def test_path_types(): path = Path.from_argv() assert isinstance(path, Path) assert isinstance(path, str) assert issubclass(Path, str)