File tree 3 files changed +20
-3
lines changed
3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -277,8 +277,12 @@ def listdir(self, path):
277
277
Args:
278
278
path (str): The path to the directory.
279
279
"""
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
282
286
283
287
def path_exists (self , path ):
284
288
command = ["test" , "-e" , path ]
Original file line number Diff line number Diff line change @@ -87,6 +87,17 @@ def test_exec_command_failure__expect_error(self):
87
87
assert b"nonexistent_command" in error
88
88
assert b"not found" in error
89
89
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
+
90
101
def test_read__text (self ):
91
102
"""
92
103
Test LocalOperations::read for text data.
Original file line number Diff line number Diff line change @@ -222,8 +222,10 @@ def test_listdir(self):
222
222
"""
223
223
path = "/etc"
224
224
files = self .operations .listdir (path )
225
-
226
225
assert isinstance (files , list )
226
+ for f in files :
227
+ assert f is not None
228
+ assert type (f ) == str # noqa: E721
227
229
228
230
def test_path_exists_true__directory (self ):
229
231
"""
You can’t perform that action at this time.
0 commit comments