@@ -41,9 +41,17 @@ def test_exec_command_failure(self):
4141try :
4242self .operations .exec_command (cmd ,verbose = True ,wait_exit = True )
4343except ExecUtilException as e :
44- assert e .message == "Utility exited with non-zero code (127). Error: `bash: line 1: nonexistent_command: command not found`"
44+ assert type (e .exit_code )== int # noqa: E721
45+ assert e .exit_code == 127
46+
47+ assert type (e .message )== str # noqa: E721
4548assert type (e .error )== bytes # noqa: E721
46- assert e .error .strip ()== b"bash: line 1: nonexistent_command: command not found"
49+
50+ assert e .message .startswith ("Utility exited with non-zero code (127). Error:" )
51+ assert "nonexistent_command" in e .message
52+ assert "not found" in e .message
53+ assert b"nonexistent_command" in e .error
54+ assert b"not found" in e .error
4755break
4856raise Exception ("We wait an exception!" )
4957
@@ -55,9 +63,11 @@ def test_exec_command_failure__expect_error(self):
5563
5664exit_status ,result ,error = self .operations .exec_command (cmd ,verbose = True ,wait_exit = True ,shell = True ,expect_error = True )
5765
58- assert error == b'bash: line 1: nonexistent_command: command not found\n '
5966assert exit_status == 127
6067assert result == b''
68+ assert type (error )== bytes # noqa: E721
69+ assert b"nonexistent_command" in error
70+ assert b"not found" in error
6171
6272def test_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- with pytest .raises (
348- ExecUtilException ,
349- match = re .escape ("cat: /dummy: No such file or directory" )):
357+ with pytest .raises (ExecUtilException )as x :
350358self .operations .read ("/dummy" )
351359
360+ assert "Utility exited with non-zero code (1)." in str (x .value )
361+ assert "No such file or directory" in str (x .value )
362+ assert "/dummy" in str (x .value )
363+
352364def test_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- with pytest .raises (ExecUtilException , match = re . escape ( "tail: cannot open '/dummy' for reading: No such file or directory" )) :
403+ with pytest .raises (ExecUtilException ) as x :
392404self .operations .read_binary ("/dummy" ,0 )
393405
406+ assert "Utility exited with non-zero code (1)." in str (x .value )
407+ assert "No such file or directory" in str (x .value )
408+ assert "/dummy" in str (x .value )
409+
394410def test_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- with pytest .raises (ExecUtilException , match = re . escape ( "du: cannot access '/dummy': No such file or directory" )) :
438+ with pytest .raises (ExecUtilException ) as x :
423439self .operations .get_file_size ("/dummy" )
424440
441+ assert "Utility exited with non-zero code (1)." in str (x .value )
442+ assert "No such file or directory" in str (x .value )
443+ assert "/dummy" in str (x .value )
444+
425445def test_touch (self ):
426446"""
427447 Test touch for creating a new file or updating access and modification times of an existing file.