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

Commitdbf6626

Browse files
Merge pull request#209 from dmitry-lipetsk/D20250311_002--tests_on_alpine
[remote] Tests are updated to support Alpine Linux
2 parentsef5493f +cf6f4cc commitdbf6626

File tree

3 files changed

+50
-12
lines changed

3 files changed

+50
-12
lines changed

‎tests/test_local.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,17 @@ def test_exec_command_failure(self):
5757
try:
5858
self.operations.exec_command(cmd,wait_exit=True,shell=True)
5959
exceptExecUtilExceptionase:
60-
asserte.message=="Utility exited with non-zero code (127). Error: `/bin/sh: 1: nonexistent_command: not found`"
60+
asserttype(e.exit_code)==int# noqa: E721
61+
asserte.exit_code==127
62+
63+
asserttype(e.message)==str# noqa: E721
6164
asserttype(e.error)==bytes# noqa: E721
62-
asserte.error.strip()==b"/bin/sh: 1: nonexistent_command: not found"
65+
66+
asserte.message.startswith("Utility exited with non-zero code (127). Error:")
67+
assert"nonexistent_command"ine.message
68+
assert"not found"ine.message
69+
assertb"nonexistent_command"ine.error
70+
assertb"not found"ine.error
6371
break
6472
raiseException("We wait an exception!")
6573

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

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

76-
asserterror==b'/bin/sh: 1: nonexistent_command: not found\n'
7784
assertexit_status==127
7885
assertresult==b''
86+
asserttype(error)==bytes# noqa: E721
87+
assertb"nonexistent_command"inerror
88+
assertb"not found"inerror
7989

8090
deftest_read__text(self):
8191
"""

‎tests/test_remote.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,17 @@ def test_exec_command_failure(self):
4141
try:
4242
self.operations.exec_command(cmd,verbose=True,wait_exit=True)
4343
exceptExecUtilExceptionase:
44-
asserte.message=="Utility exited with non-zero code (127). Error: `bash: line 1: nonexistent_command: command not found`"
44+
asserttype(e.exit_code)==int# noqa: E721
45+
asserte.exit_code==127
46+
47+
asserttype(e.message)==str# noqa: E721
4548
asserttype(e.error)==bytes# noqa: E721
46-
asserte.error.strip()==b"bash: line 1: nonexistent_command: command not found"
49+
50+
asserte.message.startswith("Utility exited with non-zero code (127). Error:")
51+
assert"nonexistent_command"ine.message
52+
assert"not found"ine.message
53+
assertb"nonexistent_command"ine.error
54+
assertb"not found"ine.error
4755
break
4856
raiseException("We wait an exception!")
4957

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

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

58-
asserterror==b'bash: line 1: nonexistent_command: command not found\n'
5966
assertexit_status==127
6067
assertresult==b''
68+
asserttype(error)==bytes# noqa: E721
69+
assertb"nonexistent_command"inerror
70+
assertb"not found"inerror
6171

6272
deftest_is_executable_true(self):
6373
"""
@@ -344,11 +354,13 @@ def test_read__unknown_file(self):
344354
Test RemoteOperations::read with unknown file.
345355
"""
346356

347-
withpytest.raises(
348-
ExecUtilException,
349-
match=re.escape("cat: /dummy: No such file or directory")):
357+
withpytest.raises(ExecUtilException)asx:
350358
self.operations.read("/dummy")
351359

360+
assert"Utility exited with non-zero code (1)."instr(x.value)
361+
assert"No such file or directory"instr(x.value)
362+
assert"/dummy"instr(x.value)
363+
352364
deftest_read_binary__spec(self):
353365
"""
354366
Test RemoteOperations::read_binary.
@@ -388,9 +400,13 @@ def test_read_binary__spec__unk_file(self):
388400
Test RemoteOperations::read_binary with unknown file.
389401
"""
390402

391-
withpytest.raises(ExecUtilException,match=re.escape("tail: cannot open '/dummy' for reading: No such file or directory")):
403+
withpytest.raises(ExecUtilException)asx:
392404
self.operations.read_binary("/dummy",0)
393405

406+
assert"Utility exited with non-zero code (1)."instr(x.value)
407+
assert"No such file or directory"instr(x.value)
408+
assert"/dummy"instr(x.value)
409+
394410
deftest_read_binary__spec__negative_offset(self):
395411
"""
396412
Test RemoteOperations::read_binary with negative offset.
@@ -419,9 +435,13 @@ def test_get_file_size__unk_file(self):
419435
Test RemoteOperations::get_file_size.
420436
"""
421437

422-
withpytest.raises(ExecUtilException,match=re.escape("du: cannot access '/dummy': No such file or directory")):
438+
withpytest.raises(ExecUtilException)asx:
423439
self.operations.get_file_size("/dummy")
424440

441+
assert"Utility exited with non-zero code (1)."instr(x.value)
442+
assert"No such file or directory"instr(x.value)
443+
assert"/dummy"instr(x.value)
444+
425445
deftest_touch(self):
426446
"""
427447
Test touch for creating a new file or updating access and modification times of an existing file.

‎tests/test_simple_remote.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ def test_init__unk_LANG_and_LC_CTYPE(self):
163163
("\"","\""),
164164
]
165165

166+
errorIsDetected=False
167+
166168
forunkDatainunkDatas:
167169
logging.info("----------------------")
168170
logging.info("Unk LANG is [{0}]".format(unkData[0]))
@@ -193,7 +195,10 @@ def test_init__unk_LANG_and_LC_CTYPE(self):
193195
assertisinstance(exc,ExecUtilException)
194196

195197
ifexcisNone:
196-
raiseException("We expected an error!")
198+
logging.warning("We expected an error!")
199+
continue
200+
201+
errorIsDetected=True
197202

198203
assertisinstance(exc,ExecUtilException)
199204

@@ -204,6 +209,9 @@ def test_init__unk_LANG_and_LC_CTYPE(self):
204209
assert"initdb: error: invalid locale settings; check LANG and LC_* environment variables"inerrMsg
205210
continue
206211

212+
ifnoterrorIsDetected:
213+
pytest.xfail("All the bad data are processed without errors!")
214+
207215
finally:
208216
__class__.helper__restore_envvar("LANG",prev_LANG)
209217
__class__.helper__restore_envvar("LANGUAGE",prev_LANGUAGE)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp