diff --git a/testgres/operations/remote_ops.py b/testgres/operations/remote_ops.py index d6917c82..60161e3c 100644 --- a/testgres/operations/remote_ops.py +++ b/testgres/operations/remote_ops.py @@ -277,8 +277,12 @@ def listdir(self, path): Args: path (str): The path to the directory. """ - result = self.exec_command("ls {}".format(path)) - return result.splitlines() + command = ["ls", path] + output = self.exec_command(cmd=command, encoding=get_default_encoding()) + assert type(output) == str # noqa: E721 + result = output.splitlines() + assert type(result) == list # noqa: E721 + return result def path_exists(self, path): command = ["test", "-e", path] diff --git a/tests/test_local.py b/tests/test_local.py index 68e7db33..3ae93f76 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -87,6 +87,17 @@ def test_exec_command_failure__expect_error(self): assert b"nonexistent_command" in error assert b"not found" in error + def test_listdir(self): + """ + Test listdir for listing directory contents. + """ + path = "/etc" + files = self.operations.listdir(path) + assert isinstance(files, list) + for f in files: + assert f is not None + assert type(f) == str # noqa: E721 + def test_read__text(self): """ Test LocalOperations::read for text data. diff --git a/tests/test_remote.py b/tests/test_remote.py index 1f771c62..2c37e2c1 100755 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -222,8 +222,10 @@ def test_listdir(self): """ path = "/etc" files = self.operations.listdir(path) - assert isinstance(files, list) + for f in files: + assert f is not None + assert type(f) == str # noqa: E721 def test_path_exists_true__directory(self): """
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: