- Notifications
You must be signed in to change notification settings - Fork35
RemoteOperations::exec_command must not raise an exception when 'expect_error' is True (#159)#160
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
dmitry-lipetsk merged 4 commits intopostgrespro:masterfromdmitry-lipetsk:D20241207_001--remote_op-expect_errorDec 8, 2024
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
4 commits Select commitHold shift + click to select a range
22c649d
test_local.py and test_exec_command_failure__expect_error are added
dmitry-lipetsk45cfbf7
RemoteOperations::exec_command must not raise an exception when 'expe…
dmitry-lipetsk1c64337
TestLocalOperations tests skip Windows
cb87d0a
tests.helpers.RunConditions is added
dmitry-lipetskFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
28 changes: 14 additions & 14 deletionstestgres/operations/remote_ops.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Empty file addedtests/__init__.py
Empty file.
Empty file addedtests/helpers/__init__.py
Empty file.
11 changes: 11 additions & 0 deletionstests/helpers/run_conditions.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import pytest | ||
import platform | ||
class RunConditions: | ||
# It is not a test kit! | ||
__test__ = False | ||
def skip_if_windows(): | ||
if platform.system().lower() == "windows": | ||
pytest.skip("This test does not support Windows.") |
54 changes: 54 additions & 0 deletionstests/test_local.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pytest | ||
from testgres import ExecUtilException | ||
from testgres import LocalOperations | ||
from .helpers.run_conditions import RunConditions | ||
class TestLocalOperations: | ||
@pytest.fixture(scope="function", autouse=True) | ||
def setup(self): | ||
self.operations = LocalOperations() | ||
def test_exec_command_success(self): | ||
""" | ||
Test exec_command for successful command execution. | ||
""" | ||
RunConditions.skip_if_windows() | ||
cmd = "python3 --version" | ||
response = self.operations.exec_command(cmd, wait_exit=True, shell=True) | ||
assert b'Python 3.' in response | ||
def test_exec_command_failure(self): | ||
""" | ||
Test exec_command for command execution failure. | ||
""" | ||
RunConditions.skip_if_windows() | ||
cmd = "nonexistent_command" | ||
while True: | ||
try: | ||
self.operations.exec_command(cmd, wait_exit=True, shell=True) | ||
except ExecUtilException as e: | ||
error = e.message | ||
break | ||
raise Exception("We wait an exception!") | ||
assert error == "Utility exited with non-zero code. Error `b'/bin/sh: 1: nonexistent_command: not found\\n'`" | ||
def test_exec_command_failure__expect_error(self): | ||
""" | ||
Test exec_command for command execution failure. | ||
""" | ||
RunConditions.skip_if_windows() | ||
cmd = "nonexistent_command" | ||
exit_status, result, error = self.operations.exec_command(cmd, verbose=True, wait_exit=True, shell=True, expect_error=True) | ||
assert error == b'/bin/sh: 1: nonexistent_command: not found\n' | ||
assert exit_status == 127 | ||
assert result == b'' |
23 changes: 19 additions & 4 deletionstests/test_remote.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.