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

OsOperations::cwd() is corrected#182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionstestgres/operations/local_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -152,6 +152,9 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
def environ(self, var_name):
return os.environ.get(var_name)

def cwd(self):
return os.getcwd()

def find_executable(self, executable):
return find_executable(executable)

Expand Down
7 changes: 1 addition & 6 deletionstestgres/operations/os_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
import getpass
import locale
import sys

try:
import psycopg2 as pglib # noqa: F401
Expand DownExpand Up@@ -39,11 +38,7 @@ def environ(self, var_name):
raise NotImplementedError()

def cwd(self):
if sys.platform == 'linux':
cmd = 'pwd'
elif sys.platform == 'win32':
cmd = 'cd'
return self.exec_command(cmd).decode().rstrip()
raise NotImplementedError()

def find_executable(self, executable):
raise NotImplementedError()
Expand Down
4 changes: 4 additions & 0 deletionstestgres/operations/remote_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -138,6 +138,10 @@ def environ(self, var_name: str) -> str:
cmd = "echo ${}".format(var_name)
return self.exec_command(cmd, encoding=get_default_encoding()).strip()

def cwd(self):
cmd = 'pwd'
return self.exec_command(cmd, encoding=get_default_encoding()).rstrip()

def find_executable(self, executable):
search_paths = self.environ("PATH")
if not search_paths:
Expand Down
17 changes: 17 additions & 0 deletionstests/test_local.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -256,3 +256,20 @@ def test_isdir_false__file(self):
response = self.operations.isdir(name)

assert response is False

def test_cwd(self):
"""
Test cwd.
"""
v = self.operations.cwd()

assert v is not None
assert type(v) == str # noqa: E721

expectedValue = os.getcwd()
assert expectedValue is not None
assert type(expectedValue) == str # noqa: E721
assert expectedValue != "" # research

# Comp result
assert v == expectedValue
10 changes: 10 additions & 0 deletionstests/test_remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -392,3 +392,13 @@ def test_isdir_false__file(self):
response = self.operations.isdir(name)

assert response is False

def test_cwd(self):
"""
Test cwd.
"""
v = self.operations.cwd()

assert v is not None
assert type(v) == str # noqa: E721
assert v != ""

[8]ページ先頭

©2009-2025 Movatter.jp