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 @@ -626,3 +626,7 @@ def get_tempdir(self) -> str:
assert type(r) is str
assert os.path.exists(r)
return r

def get_dirname(self, path: str) -> str:
assert type(path) is str
return os.path.dirname(path)
4 changes: 4 additions & 0 deletions src/os_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,7 @@ def is_port_free(self, number: int):

def get_tempdir(self) -> str:
raise NotImplementedError()

def get_dirname(self, path: str) -> str:
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 @@ -783,6 +783,10 @@ def get_tempdir(self) -> str:
assert type(temp_dir) is str
return temp_dir

def get_dirname(self, path: str) -> str:
assert type(path) is str
return posixpath.dirname(path)

@staticmethod
def _build_cmdline(cmd, exec_env: typing.Dict = None) -> str:
cmd_items = __class__._create_exec_env_list(exec_env)
Expand Down
19 changes: 19 additions & 0 deletions tests/test_os_ops_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1396,3 +1396,22 @@ def test_kill__unk_pid(
RuntimeError("Unknown os_ops type: {}".format(type(os_ops).__name__))

return

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

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

expected_dirname = os.path.dirname(p)
assert type(expected_dirname) is str
assert expected_dirname != ""

actual_dirname = os_ops.get_dirname(p)
assert type(actual_dirname) is str
assert actual_dirname != ""

assert actual_dirname == expected_dirname
return