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

Commit4493d69

Browse files
OsOperations::cwd() is corrected (#182)
* OsOperations::cwd() is correctedThis patch fixes the following problems: - It does not work on Windows - It always returns LOCAL path
1 parent737e0b4 commit4493d69

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

‎testgres/operations/local_ops.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
152152
defenviron(self,var_name):
153153
returnos.environ.get(var_name)
154154

155+
defcwd(self):
156+
returnos.getcwd()
157+
155158
deffind_executable(self,executable):
156159
returnfind_executable(executable)
157160

‎testgres/operations/os_ops.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
importgetpass
22
importlocale
3-
importsys
43

54
try:
65
importpsycopg2aspglib# noqa: F401
@@ -39,11 +38,7 @@ def environ(self, var_name):
3938
raiseNotImplementedError()
4039

4140
defcwd(self):
42-
ifsys.platform=='linux':
43-
cmd='pwd'
44-
elifsys.platform=='win32':
45-
cmd='cd'
46-
returnself.exec_command(cmd).decode().rstrip()
41+
raiseNotImplementedError()
4742

4843
deffind_executable(self,executable):
4944
raiseNotImplementedError()

‎testgres/operations/remote_ops.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ def environ(self, var_name: str) -> str:
138138
cmd="echo ${}".format(var_name)
139139
returnself.exec_command(cmd,encoding=get_default_encoding()).strip()
140140

141+
defcwd(self):
142+
cmd='pwd'
143+
returnself.exec_command(cmd,encoding=get_default_encoding()).rstrip()
144+
141145
deffind_executable(self,executable):
142146
search_paths=self.environ("PATH")
143147
ifnotsearch_paths:

‎tests/test_local.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,20 @@ def test_isdir_false__file(self):
256256
response=self.operations.isdir(name)
257257

258258
assertresponseisFalse
259+
260+
deftest_cwd(self):
261+
"""
262+
Test cwd.
263+
"""
264+
v=self.operations.cwd()
265+
266+
assertvisnotNone
267+
asserttype(v)==str# noqa: E721
268+
269+
expectedValue=os.getcwd()
270+
assertexpectedValueisnotNone
271+
asserttype(expectedValue)==str# noqa: E721
272+
assertexpectedValue!=""# research
273+
274+
# Comp result
275+
assertv==expectedValue

‎tests/test_remote.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,3 +392,13 @@ def test_isdir_false__file(self):
392392
response=self.operations.isdir(name)
393393

394394
assertresponseisFalse
395+
396+
deftest_cwd(self):
397+
"""
398+
Test cwd.
399+
"""
400+
v=self.operations.cwd()
401+
402+
assertvisnotNone
403+
asserttype(v)==str# noqa: E721
404+
assertv!=""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp