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

Commit3a1d08b

Browse files
RemoteOperations::path_exists is updated (#206)
- command is passed through list- we process all the result codes of test
1 parente1a5bb4 commit3a1d08b

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
@@ -247,8 +247,30 @@ def listdir(self, path):
247247
returnresult.splitlines()
248248

249249
defpath_exists(self,path):
250-
result=self.exec_command("test -e {}; echo $?".format(path),encoding=get_default_encoding())
251-
returnint(result.strip())==0
250+
command= ["test","-e",path]
251+
252+
exit_status,output,error=self.exec_command(cmd=command,encoding=get_default_encoding(),ignore_errors=True,verbose=True)
253+
254+
asserttype(output)==str# noqa: E721
255+
asserttype(error)==str# noqa: E721
256+
257+
ifexit_status==0:
258+
returnTrue
259+
260+
ifexit_status==1:
261+
returnFalse
262+
263+
errMsg="Test operation returns an unknown result code: {0}. Path is [{1}].".format(
264+
exit_status,
265+
path)
266+
267+
RaiseError.CommandExecutionError(
268+
cmd=command,
269+
exit_code=exit_status,
270+
msg_arg=errMsg,
271+
error=error,
272+
out=output
273+
)
252274

253275
@property
254276
defpathsep(self):

‎tests/test_remote.py

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

131131
assertisinstance(files,list)
132132

133-
deftest_path_exists_true(self):
133+
deftest_path_exists_true__directory(self):
134134
"""
135-
Test path_exists for an existingpath.
135+
Test path_exists for an existingdirectory.
136136
"""
137-
path="/etc"
138-
response=self.operations.path_exists(path)
137+
assertself.operations.path_exists("/etc")isTrue
139138

140-
assertresponseisTrue
139+
deftest_path_exists_true__file(self):
140+
"""
141+
Test path_exists for an existing file.
142+
"""
143+
assertself.operations.path_exists(__file__)isTrue
141144

142-
deftest_path_exists_false(self):
145+
deftest_path_exists_false__directory(self):
143146
"""
144-
Test path_exists for a non-existingpath.
147+
Test path_exists for a non-existingdirectory.
145148
"""
146-
path="/nonexistent_path"
147-
response=self.operations.path_exists(path)
149+
assertself.operations.path_exists("/nonexistent_path")isFalse
148150

149-
assertresponseisFalse
151+
deftest_path_exists_false__file(self):
152+
"""
153+
Test path_exists for a non-existing file.
154+
"""
155+
assertself.operations.path_exists("/etc/nonexistent_path.txt")isFalse
150156

151157
deftest_write_text_file(self):
152158
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp