diff --git a/exec_helpers/exec_result.py b/exec_helpers/exec_result.py index 7401f91..16317ad 100644 --- a/exec_helpers/exec_result.py +++ b/exec_helpers/exec_result.py @@ -425,12 +425,7 @@ def __str__(self): # type: () -> str def __eq__(self, other): # type: (typing.Any) -> bool """Comparision.""" - return all( - ( - getattr(self, val) == getattr(other, val) - for val in ['cmd', 'stdout', 'stderr', 'exit_code'] - ) - ) + return hash(self) == hash(other) def __ne__(self, other): # type: (typing.Any) -> bool """Comparision.""" @@ -440,6 +435,6 @@ def __hash__(self): """Hash for usage as dict key and in sets.""" return hash( ( - self.__class__, self.cmd, self.stdout, self.stderr, + self.__class__, self.cmd, self.stdin, self.stdout, self.stderr, self.exit_code )) diff --git a/test/test_exec_result.py b/test/test_exec_result.py index ea2c9b1..f06173a 100644 --- a/test/test_exec_result.py +++ b/test/test_exec_result.py @@ -105,6 +105,7 @@ def test_create_minimal(self, logger): ( exec_helpers.ExecResult, cmd, + None, (), (), exec_helpers.ExitCodes.EX_INVALID diff --git a/test/test_subprocess_runner.py b/test/test_subprocess_runner.py index 18d508d..ff1020d 100644 --- a/test/test_subprocess_runner.py +++ b/test/test_subprocess_runner.py @@ -564,7 +564,7 @@ def test_006_check_stdin_bytearray( ): # type: (...) -> None stdin = bytearray(b'this is a line') - popen_obj, exp_result = self.prepare_close(popen, cmd=print_stdin, stdout_override=[stdin]) + popen_obj, exp_result = self.prepare_close(popen, cmd=print_stdin, stdout_override=[bytes(l) for l in stdin]) stdin_mock = mock.Mock() popen_obj.attach_mock(stdin_mock, 'stdin')