Skip to content

Commit 230e562

Browse files
RemoteOperations::listdir is corrected (#217)
- It returns list[str] - New asserts are added Tests for listdir are updated.
1 parent e3eb6ae commit 230e562

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

testgres/operations/remote_ops.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,12 @@ def listdir(self, path):
277277
Args:
278278
path (str): The path to the directory.
279279
"""
280-
result = self.exec_command("ls {}".format(path))
281-
return result.splitlines()
280+
command = ["ls", path]
281+
output = self.exec_command(cmd=command, encoding=get_default_encoding())
282+
assert type(output) == str # noqa: E721
283+
result = output.splitlines()
284+
assert type(result) == list # noqa: E721
285+
return result
282286

283287
def path_exists(self, path):
284288
command = ["test", "-e", path]

tests/test_local.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ def test_exec_command_failure__expect_error(self):
8787
assert b"nonexistent_command" in error
8888
assert b"not found" in error
8989

90+
def test_listdir(self):
91+
"""
92+
Test listdir for listing directory contents.
93+
"""
94+
path = "/etc"
95+
files = self.operations.listdir(path)
96+
assert isinstance(files, list)
97+
for f in files:
98+
assert f is not None
99+
assert type(f) == str # noqa: E721
100+
90101
def test_read__text(self):
91102
"""
92103
Test LocalOperations::read for text data.

tests/test_remote.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,10 @@ def test_listdir(self):
222222
"""
223223
path = "/etc"
224224
files = self.operations.listdir(path)
225-
226225
assert isinstance(files, list)
226+
for f in files:
227+
assert f is not None
228+
assert type(f) == str # noqa: E721
227229

228230
def test_path_exists_true__directory(self):
229231
"""

0 commit comments

Comments
 (0)
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