Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/local_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,3 +630,7 @@ def get_tempdir(self) -> str:
def get_dirname(self, path: str) -> str:
assert type(path) is str
return os.path.dirname(path)

def is_abs_path(self, path: str) -> bool:
assert type(path) is str
return os.path.isabs(path)
4 changes: 4 additions & 0 deletions src/os_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,7 @@ def get_tempdir(self) -> str:
def get_dirname(self, path: str) -> str:
assert type(path) is str
raise NotImplementedError()

def is_abs_path(self, path: str) -> bool:
assert type(path) is str
raise NotImplementedError()
4 changes: 4 additions & 0 deletions src/remote_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,10 @@ def get_dirname(self, path: str) -> str:
assert type(path) is str
return posixpath.dirname(path)

def is_abs_path(self, path: str) -> bool:
assert type(path) is str
return posixpath.isabs(path)

@staticmethod
def _build_cmdline(cmd, exec_env: typing.Dict = None) -> str:
cmd_items = __class__._create_exec_env_list(exec_env)
Expand Down
26 changes: 26 additions & 0 deletions tests/test_os_ops_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1415,3 +1415,29 @@ def test_get_dirname(self, os_ops: OsOperations):

assert actual_dirname == expected_dirname
return

def test_is_abs_path__yes(self, os_ops: OsOperations):
assert isinstance(os_ops, OsOperations)

p = __file__
assert type(p) is str
assert p != ""
assert os.path.isabs(p)

actual_value = os_ops.is_abs_path(p)
assert type(actual_value) is bool

assert actual_value is True
return

def test_is_abs_path__no(self, os_ops: OsOperations):
assert isinstance(os_ops, OsOperations)

p = "."
assert not os.path.isabs(p)

actual_value = os_ops.is_abs_path(p)
assert type(actual_value) is bool

assert actual_value is False
return