Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f65dcb

Browse files
Merge branch 'master' into D20250303_002--os_ops-rmdirs
2 parents319a9d9 +3a1d08b commit9f65dcb

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed

‎testgres/operations/remote_ops.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,30 @@ def listdir(self, path):
273273
returnresult.splitlines()
274274

275275
defpath_exists(self,path):
276-
result=self.exec_command("test -e {}; echo $?".format(path),encoding=get_default_encoding())
277-
returnint(result.strip())==0
276+
command= ["test","-e",path]
277+
278+
exit_status,output,error=self.exec_command(cmd=command,encoding=get_default_encoding(),ignore_errors=True,verbose=True)
279+
280+
asserttype(output)==str# noqa: E721
281+
asserttype(error)==str# noqa: E721
282+
283+
ifexit_status==0:
284+
returnTrue
285+
286+
ifexit_status==1:
287+
returnFalse
288+
289+
errMsg="Test operation returns an unknown result code: {0}. Path is [{1}].".format(
290+
exit_status,
291+
path)
292+
293+
RaiseError.CommandExecutionError(
294+
cmd=command,
295+
exit_code=exit_status,
296+
msg_arg=errMsg,
297+
error=error,
298+
out=output
299+
)
278300

279301
@property
280302
defpathsep(self):

‎tests/test_remote.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,29 @@ def test_listdir(self):
198198

199199
assertisinstance(files,list)
200200

201-
deftest_path_exists_true(self):
201+
deftest_path_exists_true__directory(self):
202202
"""
203-
Test path_exists for an existingpath.
203+
Test path_exists for an existingdirectory.
204204
"""
205-
path="/etc"
206-
response=self.operations.path_exists(path)
205+
assertself.operations.path_exists("/etc")isTrue
207206

208-
assertresponseisTrue
207+
deftest_path_exists_true__file(self):
208+
"""
209+
Test path_exists for an existing file.
210+
"""
211+
assertself.operations.path_exists(__file__)isTrue
209212

210-
deftest_path_exists_false(self):
213+
deftest_path_exists_false__directory(self):
211214
"""
212-
Test path_exists for a non-existingpath.
215+
Test path_exists for a non-existingdirectory.
213216
"""
214-
path="/nonexistent_path"
215-
response=self.operations.path_exists(path)
217+
assertself.operations.path_exists("/nonexistent_path")isFalse
216218

217-
assertresponseisFalse
219+
deftest_path_exists_false__file(self):
220+
"""
221+
Test path_exists for a non-existing file.
222+
"""
223+
assertself.operations.path_exists("/etc/nonexistent_path.txt")isFalse
218224

219225
deftest_write_text_file(self):
220226
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp