From 61ff4cd4f8401d6b5f80cb7d5a67b2246c7cbb46 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Thu, 13 Mar 2025 23:08:08 +0300 Subject: [PATCH] RemoteOperations::listdir is corrected - It returns list[str] - New asserts are added Tests for listdir are updated. --- testgres/operations/remote_ops.py | 8 ++++++-- tests/test_local.py | 11 +++++++++++ tests/test_remote.py | 4 +++- 3 files changed, 20 insertions(+), 3 deletions(-) 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): """ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy