From b36f847014b3fcd83505d779e71751ab1dd8267f Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Thu, 4 Jun 2026 18:32:54 +0300 Subject: [PATCH] new: OsOperations::is_abs_path is added --- src/local_ops.py | 4 ++++ src/os_ops.py | 4 ++++ src/remote_ops.py | 4 ++++ tests/test_os_ops_common.py | 26 ++++++++++++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/src/local_ops.py b/src/local_ops.py index cb51682..52d94dc 100644 --- a/src/local_ops.py +++ b/src/local_ops.py @@ -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) diff --git a/src/os_ops.py b/src/os_ops.py index 8ba6983..09d02d2 100644 --- a/src/os_ops.py +++ b/src/os_ops.py @@ -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() diff --git a/src/remote_ops.py b/src/remote_ops.py index b2b2efb..a9f0164 100644 --- a/src/remote_ops.py +++ b/src/remote_ops.py @@ -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) diff --git a/tests/test_os_ops_common.py b/tests/test_os_ops_common.py index 0d74eba..14786f3 100644 --- a/tests/test_os_ops_common.py +++ b/tests/test_os_ops_common.py @@ -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