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

[remote] Tests are updated to support Alpine Linux#209

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
16 changes: 13 additions & 3 deletionstests/test_local.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,9 +57,17 @@ def test_exec_command_failure(self):
try:
self.operations.exec_command(cmd, wait_exit=True, shell=True)
except ExecUtilException as e:
assert e.message == "Utility exited with non-zero code (127). Error: `/bin/sh: 1: nonexistent_command: not found`"
assert type(e.exit_code) == int # noqa: E721
assert e.exit_code == 127

assert type(e.message) == str # noqa: E721
assert type(e.error) == bytes # noqa: E721
assert e.error.strip() == b"/bin/sh: 1: nonexistent_command: not found"

assert e.message.startswith("Utility exited with non-zero code (127). Error:")
assert "nonexistent_command" in e.message
assert "not found" in e.message
assert b"nonexistent_command" in e.error
assert b"not found" in e.error
break
raise Exception("We wait an exception!")

Expand All@@ -73,9 +81,11 @@ def test_exec_command_failure__expect_error(self):

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''
assert type(error) == bytes # noqa: E721
assert b"nonexistent_command" in error
assert b"not found" in error

def test_read__text(self):
"""
Expand Down
36 changes: 28 additions & 8 deletionstests/test_remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,9 +41,17 @@ def test_exec_command_failure(self):
try:
self.operations.exec_command(cmd, verbose=True, wait_exit=True)
except ExecUtilException as e:
assert e.message == "Utility exited with non-zero code (127). Error: `bash: line 1: nonexistent_command: command not found`"
assert type(e.exit_code) == int # noqa: E721
assert e.exit_code == 127

assert type(e.message) == str # noqa: E721
assert type(e.error) == bytes # noqa: E721
assert e.error.strip() == b"bash: line 1: nonexistent_command: command not found"

assert e.message.startswith("Utility exited with non-zero code (127). Error:")
assert "nonexistent_command" in e.message
assert "not found" in e.message
assert b"nonexistent_command" in e.error
assert b"not found" in e.error
break
raise Exception("We wait an exception!")

Expand All@@ -55,9 +63,11 @@ def test_exec_command_failure__expect_error(self):

exit_status, result, error = self.operations.exec_command(cmd, verbose=True, wait_exit=True, shell=True, expect_error=True)

assert error == b'bash: line 1: nonexistent_command: command not found\n'
assert exit_status == 127
assert result == b''
assert type(error) == bytes # noqa: E721
assert b"nonexistent_command" in error
assert b"not found" in error

def test_is_executable_true(self):
"""
Expand DownExpand Up@@ -344,11 +354,13 @@ def test_read__unknown_file(self):
Test RemoteOperations::read with unknown file.
"""

with pytest.raises(
ExecUtilException,
match=re.escape("cat: /dummy: No such file or directory")):
with pytest.raises(ExecUtilException) as x:
self.operations.read("/dummy")

assert "Utility exited with non-zero code (1)." in str(x.value)
assert "No such file or directory" in str(x.value)
assert "/dummy" in str(x.value)

def test_read_binary__spec(self):
"""
Test RemoteOperations::read_binary.
Expand DownExpand Up@@ -388,9 +400,13 @@ def test_read_binary__spec__unk_file(self):
Test RemoteOperations::read_binary with unknown file.
"""

with pytest.raises(ExecUtilException, match=re.escape("tail: cannot open '/dummy' for reading: No such file or directory")):
with pytest.raises(ExecUtilException) as x:
self.operations.read_binary("/dummy", 0)

assert "Utility exited with non-zero code (1)." in str(x.value)
assert "No such file or directory" in str(x.value)
assert "/dummy" in str(x.value)

def test_read_binary__spec__negative_offset(self):
"""
Test RemoteOperations::read_binary with negative offset.
Expand DownExpand Up@@ -419,9 +435,13 @@ def test_get_file_size__unk_file(self):
Test RemoteOperations::get_file_size.
"""

with pytest.raises(ExecUtilException, match=re.escape("du: cannot access '/dummy': No such file or directory")):
with pytest.raises(ExecUtilException) as x:
self.operations.get_file_size("/dummy")

assert "Utility exited with non-zero code (1)." in str(x.value)
assert "No such file or directory" in str(x.value)
assert "/dummy" in str(x.value)

def test_touch(self):
"""
Test touch for creating a new file or updating access and modification times of an existing file.
Expand Down
10 changes: 9 additions & 1 deletiontests/test_simple_remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -163,6 +163,8 @@ def test_init__unk_LANG_and_LC_CTYPE(self):
("\"", "\""),
]

errorIsDetected = False

for unkData in unkDatas:
logging.info("----------------------")
logging.info("Unk LANG is [{0}]".format(unkData[0]))
Expand DownExpand Up@@ -193,7 +195,10 @@ def test_init__unk_LANG_and_LC_CTYPE(self):
assert isinstance(exc, ExecUtilException)

if exc is None:
raise Exception("We expected an error!")
logging.warning("We expected an error!")
continue

errorIsDetected = True

assert isinstance(exc, ExecUtilException)

Expand All@@ -204,6 +209,9 @@ def test_init__unk_LANG_and_LC_CTYPE(self):
assert "initdb: error: invalid locale settings; check LANG and LC_* environment variables" in errMsg
continue

if not errorIsDetected:
pytest.xfail("All the bad data are processed without errors!")

finally:
__class__.helper__restore_envvar("LANG", prev_LANG)
__class__.helper__restore_envvar("LANGUAGE", prev_LANGUAGE)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp