diff --git a/testgres/operations/local_ops.py b/testgres/operations/local_ops.py index 8bdb22cd..fc3e3954 100644 --- a/testgres/operations/local_ops.py +++ b/testgres/operations/local_ops.py @@ -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) diff --git a/testgres/operations/os_ops.py b/testgres/operations/os_ops.py index 35525b3c..00880863 100644 --- a/testgres/operations/os_ops.py +++ b/testgres/operations/os_ops.py @@ -1,6 +1,5 @@ import getpass import locale -import sys try: import psycopg2 as pglib # noqa: F401 @@ -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() diff --git a/testgres/operations/remote_ops.py b/testgres/operations/remote_ops.py index 2f34ecec..3ebc2e60 100644 --- a/testgres/operations/remote_ops.py +++ b/testgres/operations/remote_ops.py @@ -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: diff --git a/tests/test_local.py b/tests/test_local.py index d7adce17..568a4bc5 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -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 diff --git a/tests/test_remote.py b/tests/test_remote.py index 7071a9d9..30c5d348 100755 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -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 != ""
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: